西安网络赛三道水题 HDU 5007 HDU 5011 HDU 5015
2014-09-17 00:38
363 查看
HDU5007
Total Submission(s): 348 Accepted Submission(s): 274
Problem Description
DT is a big fan of digital products. He writes posts about technological products almost everyday in his blog.
But there is such few comments of his posts that he feels depressed all the day. As his best friend and an excellent programmer, DT asked you to help make his blog look more popular. He is so warm that you have no idea how to refuse. But you are unwilling to
read all of his boring posts word by word. So you decided to write a script to comment below his posts automatically.
After observation, you found words “Apple” appear everywhere in his posts. After your counting, you concluded that “Apple”, “iPhone”, “iPod”, “iPad” are the most high-frequency words in his blog. Once one of these words were read by your smart script, it will
make a comment “MAI MAI MAI!”, and go on reading the post.
In order to make it more funny, you, as a fan of Sony, also want to make some comments about Sony. So you want to add a new rule to the script: make a comment “SONY DAFA IS GOOD!” when “Sony” appears.
Input
A blog article described above, which contains only printable characters(whose ASCII code is between 32 and 127), CR(ASCII code 13, ‘\r’ in C/C++), LF(ASCII code 10, ‘\n’ in C/C++), please process input until EOF. Note all characters
are case sensitive.
The size of the article does not exceed 8KB.
Output
Output should contains comments generated by your script, one per line.
Sample Input
Sample Output
签到题,判断一个串中出现了形如APP类产品的就输出MAIMAIMAI 有SONY的就输出索尼大法好,GETS读入胡搞一下。。。
HDU5011
Total Submission(s): 342 Accepted Submission(s): 264
Problem Description
Here is a game for two players. The rule of the game is described below:
● In the beginning of the game, there are a lot of piles of beads.
● Players take turns to play. Each turn, player choose a pile i and remove some (at least one) beads from it. Then he could do nothing or split pile i into two piles with a beads and b beads.(a,b > 0 and a + b equals to the number of beads of pile i after removing)
● If after a player's turn, there is no beads left, the player is the winner.
Suppose that the two players are all very clever and they will use optimal game strategies. Your job is to tell whether the player who plays first can win the game.
Input
There are multiple test cases. Please process till EOF.
For each test case, the first line contains a postive integer n(n < 105) means there are n piles of beads. The next line contains n postive integer, the i-th postive integer ai(ai < 231) means there are ai
beads in the i-th pile.
Output
For each test case, if the first player can win the game, ouput "Win" and if he can't, ouput "Lose"
Sample Input
Sample Output
Source
2014 ACM/ICPC Asia Regional Xi'an Online
题意 :取石子游戏,两个人轮流取石子,取石子有规则,要么那掉这堆石子,要么将这堆石子分成两堆,在加入原来的石堆当中,先手取完算胜利,否则失败。
思路:简单NIM,所有值异或为0,则跪,找规律找出来的= =。。。
Total Submission(s): 587 Accepted Submission(s): 367
Problem Description
In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be
233, 2333, 23333... (it means a0,1 = 233,a0,2 = 2333,a0,3 = 23333...) Besides, in 233 matrix, we got ai,j = ai-1,j +ai,j-1( i,j ≠ 0). Now you have known a1,0,a2,0,...,an,0,
could you tell me an,m in the 233 matrix?
Input
There are multiple test cases. Please process till EOF.
For each case, the first line contains two postive integers n,m(n ≤ 10,m ≤ 109). The second line contains n integers, a1,0,a2,0,...,an,0(0 ≤ ai,0 < 231).
Output
For each case, output an,m mod 10000007.
Sample Input
Sample Output
Source
2014 ACM/ICPC Asia Regional Xi'an Online
不想多说,心塞塞的一题,用数学方法推也推出来了,一写MLE,后来别的队构造矩阵过了,然后自己就去构造了,很显然要加2维一个维护形如233这个值,另一个要加上当前元素的值,所以N+2阶的矩阵很好构造= =。。。忧桑,早知道早就去构造矩阵不用纯数学方法了,更心塞的是这题纯数学方法是能过的,不过那个大神开的求逆元的数组只开了11我却开了1E7+7不跪才怪了= =。。。
目测三个赛区都进了= =,不过深深感到我好酱油啊 不开森不开森啊= =。。。
Post Robot
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 348 Accepted Submission(s): 274
Problem Description
DT is a big fan of digital products. He writes posts about technological products almost everyday in his blog.
But there is such few comments of his posts that he feels depressed all the day. As his best friend and an excellent programmer, DT asked you to help make his blog look more popular. He is so warm that you have no idea how to refuse. But you are unwilling to
read all of his boring posts word by word. So you decided to write a script to comment below his posts automatically.
After observation, you found words “Apple” appear everywhere in his posts. After your counting, you concluded that “Apple”, “iPhone”, “iPod”, “iPad” are the most high-frequency words in his blog. Once one of these words were read by your smart script, it will
make a comment “MAI MAI MAI!”, and go on reading the post.
In order to make it more funny, you, as a fan of Sony, also want to make some comments about Sony. So you want to add a new rule to the script: make a comment “SONY DAFA IS GOOD!” when “Sony” appears.
Input
A blog article described above, which contains only printable characters(whose ASCII code is between 32 and 127), CR(ASCII code 13, ‘\r’ in C/C++), LF(ASCII code 10, ‘\n’ in C/C++), please process input until EOF. Note all characters
are case sensitive.
The size of the article does not exceed 8KB.
Output
Output should contains comments generated by your script, one per line.
Sample Input
Apple bananaiPad lemon ApplepiSony 233 Tim cook is doubi from Apple iPhoneipad iPhone30 is so biiiiiiig Microsoft makes good App.
Sample Output
MAI MAI MAI! MAI MAI MAI! MAI MAI MAI! SONY DAFA IS GOOD! MAI MAI MAI! MAI MAI MAI! MAI MAI MAI!
签到题,判断一个串中出现了形如APP类产品的就输出MAIMAIMAI 有SONY的就输出索尼大法好,GETS读入胡搞一下。。。
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> using namespace std; char s[2000005]; int main() { while(gets(s)) { int len=strlen(s); for(int i=0;i<len;i++) { if(s[i]=='A'&&s[i+1]=='p'&&s[i+2]=='p'&&s[i+3]=='l'&&s[i+4]=='e') { printf("MAI MAI MAI!\n"); } if(s[i]=='i'&&s[i+1]=='P'&&s[i+2]=='h'&&s[i+3]=='o'&&s[i+4]=='n'&&s[i+5]=='e') { printf("MAI MAI MAI!\n"); } if(s[i]=='i'&&s[i+1]=='P'&&s[i+2]=='a'&&s[i+3]=='d') { printf("MAI MAI MAI!\n"); } if(s[i]=='i'&&s[i+1]=='P'&&s[i+2]=='o'&&s[i+3]=='d') { printf("MAI MAI MAI!\n"); } if(s[i]=='S'&&s[i+1]=='o'&&s[i+2]=='n'&&s[i+3]=='y') { printf("SONY DAFA IS GOOD!\n"); } } } return 0; }
HDU5011
Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 342 Accepted Submission(s): 264
Problem Description
Here is a game for two players. The rule of the game is described below:
● In the beginning of the game, there are a lot of piles of beads.
● Players take turns to play. Each turn, player choose a pile i and remove some (at least one) beads from it. Then he could do nothing or split pile i into two piles with a beads and b beads.(a,b > 0 and a + b equals to the number of beads of pile i after removing)
● If after a player's turn, there is no beads left, the player is the winner.
Suppose that the two players are all very clever and they will use optimal game strategies. Your job is to tell whether the player who plays first can win the game.
Input
There are multiple test cases. Please process till EOF.
For each test case, the first line contains a postive integer n(n < 105) means there are n piles of beads. The next line contains n postive integer, the i-th postive integer ai(ai < 231) means there are ai
beads in the i-th pile.
Output
For each test case, if the first player can win the game, ouput "Win" and if he can't, ouput "Lose"
Sample Input
1 1 2 1 1 3 1 2 3
Sample Output
Win Lose Lose
Source
2014 ACM/ICPC Asia Regional Xi'an Online
题意 :取石子游戏,两个人轮流取石子,取石子有规则,要么那掉这堆石子,要么将这堆石子分成两堆,在加入原来的石堆当中,先手取完算胜利,否则失败。
思路:简单NIM,所有值异或为0,则跪,找规律找出来的= =。。。
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> using namespace std; int n; long long a, sum; int main() { while (~scanf("%d", &n)) { sum = 0; for (int i = 0 ; i < n; i++) { scanf("%I64d", &a); sum ^= a; } if (sum == 0) printf("Lose\n"); else printf("Win\n"); } return 0; }
233 Matrix
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 587 Accepted Submission(s): 367
Problem Description
In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be
233, 2333, 23333... (it means a0,1 = 233,a0,2 = 2333,a0,3 = 23333...) Besides, in 233 matrix, we got ai,j = ai-1,j +ai,j-1( i,j ≠ 0). Now you have known a1,0,a2,0,...,an,0,
could you tell me an,m in the 233 matrix?
Input
There are multiple test cases. Please process till EOF.
For each case, the first line contains two postive integers n,m(n ≤ 10,m ≤ 109). The second line contains n integers, a1,0,a2,0,...,an,0(0 ≤ ai,0 < 231).
Output
For each case, output an,m mod 10000007.
Sample Input
1 1 1 2 2 0 0 3 7 23 47 16
Sample Output
234 2799 72937 Hint
Source
2014 ACM/ICPC Asia Regional Xi'an Online
不想多说,心塞塞的一题,用数学方法推也推出来了,一写MLE,后来别的队构造矩阵过了,然后自己就去构造了,很显然要加2维一个维护形如233这个值,另一个要加上当前元素的值,所以N+2阶的矩阵很好构造= =。。。忧桑,早知道早就去构造矩阵不用纯数学方法了,更心塞的是这题纯数学方法是能过的,不过那个大神开的求逆元的数组只开了11我却开了1E7+7不跪才怪了= =。。。
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> using namespace std; long long n,m; const long long mod=(long long )(1e7+7); long long b[25]; struct juzhen{ long long m[15][15]; }; juzhen mut(juzhen a,juzhen b) { juzhen c; for(long long i=0;i<n+2;i++) { for(long long j=0;j<n+2;j++) { c.m[i][j]=0; for(long long k=0;k<n+2;k++) { c.m[i][j]+=(a.m[i][k]*b.m[k][j])%mod; c.m[i][j]%=mod; } } } return c; } juzhen power(juzhen a,long long p) { juzhen ans; memset(ans.m,0,sizeof(ans.m)); for(long long i=0;i<n+2;i++) { ans.m[i][i]=1; } while(p) { if(p&1) ans=mut(ans,a); a=mut(a,a); p>>=1; } return ans; } int main() { while(cin>>n>>m) { for(long long i=0;i<n;i++) { cin>>b[i]; } b =23; b[n+1]=3; juzhen ans; memset(ans.m,0,sizeof(ans.m)); for(long long i=0;i<n;i++) { for(long long j=0;j<=i;j++) { ans.m[i][j]=1; } } for(long long i=0;i<=n;i++) { ans.m[i] =10; } for(long long i=0;i<=n+1;i++) { ans.m[i][n+1]=1; } ans=power(ans,m); long long res=0; for(long long i=0;i<n+2;i++) { res+=ans.m[n-1][i]*b[i]%mod; res%=mod; } cout<<res<<endl; } return 0; }
目测三个赛区都进了= =,不过深深感到我好酱油啊 不开森不开森啊= =。。。
相关文章推荐
- hdu 5015 233 Matrix(西安网络赛 1009)
- HDU 5015 233 Matrix(西安网络赛I题, 构造矩阵)
- HDU 5007 Post Robot(西安网络赛A题)
- HDU 5015 矩阵优化 (2014西安网络赛)
- HDU 5011 Game(西安网络赛E题)
- hdu 5011 Game(2014 西安网络赛)
- hdu 5015 233 Matrix 2014年西安网络赛I题
- HDU 5015 233 Matrix(西安网络赛I题)
- hdu 5015 233 Matrix(西安网络赛1009)【构造矩阵】
- HDU 5007 Post Robot KMP (ICPC西安赛区网络预选赛 1001)
- HDOJ 5007 Post Robot--2014网络赛西安赛区A题
- hdu 2014西安赛区网络赛 5011Game
- hdu 5014 Number Sequence 西安网络赛
- hdu 5017 Ellipsoid(西安网络赛 1011)
- HDU 5008 (2014西安网络赛第二题)后缀数组
- hdu 5014 Number Sequence(西安网络赛1008)
- HDU 5008西安网络赛B题:后缀数组求第k小子串
- hdu 5012 Dice(西安网络赛F题,BFS)
- HDU 5014 Number Sequence(西安网络赛H题)
- HDU 5015 233 Matrix(网络赛1009) 矩阵快速幂