online_judge_1006

来源:互联网 发布:panabit官网端口 编辑:程序博客网 时间:2024/06/13 03:21
<span style="font-size:18px;">#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){    char s[1000];    while(scanf("%s",s)!=EOF)    {         if(!strstr(s,"z")||!strstr(s,"j")||!strstr(s,"o"))         {              printf("Wrong Answer\n");              continue;         }         int c_z=0,c_j=0,i=0;         while(s[i]&&c_z>=c_j)         {              if(s[i]=='z') c_z++;              else if(s[i]=='j') c_j++;              i++;         }         if(c_z!=1||c_j!=1)         {              printf("Wrong Answer\n");              continue;         }         int e1=0,e2=0,e3=0;         int j=0;         while(s[j++]!='z')          e1++;         while(s[j++]!='j')          e2++;         while(s[j++])          e3++;         if(e2!=0&&e1*e2==e3)          printf("Accepted\n");         else          printf("Wrong Answer\n");    }    return 0;} /**************************************************************    Problem: 1006    User: 2499088506    Language: C    Result: Accepted    Time:30 ms    Memory:912 kb****************************************************************/</span>
这道题目我做了好久好久,主要是题目的意思没有弄懂!真心无法下手。最后在网上看
到大虾给出的题目解析报告才知道题目的意思。做出来了。字符z和j之间至少要有一个
字符o,而z之前的字符数量和z与j之间的字符数量的乘积等于j之后的字符数量!

0 0
原创粉丝点击