ZOJ问题
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2859 Accepted Submission(s): 862
Problem Description
对给定的字符串(只包含‘z‘,‘o‘,‘j‘三种字符),判断他是否能AC。
是否AC的规则如下:
1. zoj能AC;
2. 若字符串形式为xzojx,则也能AC,其中x可以是N个‘o‘ 或者为空;
3. 若azbjc 能AC,则azbojac也能AC,其中a,b,c为N个‘o‘或者为空;
Input
输入包含多组测试用例,每行有一个只包含‘z‘,‘o‘,‘j‘三种字符的字符串,字符串长度小于等于1000;
Output
对于给定的字符串,如果能AC则请输出字符串“Accepted”,否则请输出“Wrong Answer”。
Sample Input
zoj ozojo ozoojoo oozoojoooo zooj ozojo oooozojo zojoooo
Sample Output
Accepted Accepted Accepted Accepted Accepted Accepted Wrong Answer Wrong Answer
Source
//a*b==c即Aceeptd,a表示z之前o的个数, //b表示zj之间o的个数,c表示j之后o个数 #include<stdio.h> #include<string.h> char s[1002]; int main() { int i,len,a,b,c,d,e; while(scanf("%s",s)!=EOF) { len=strlen(s); for(i=0;i<len;i++) { if(s[i]=='z') a=i; if(s[i]=='j') b=i-a-1; } c=len-a-b-2; if(a==0) { if(b>0&&c==0) printf("Accepted\n"); else printf("Wrong Answer\n"); } else { if(a*b==c&&b>0) printf("Accepted\n"); else printf("Wrong Answer\n"); } } return 0; }
时间: 2024-10-07 05:14:04