Topic 1006:zoj Questions
Time limit: 1 seconds
Memory Limit: 32 MB
Special question: No
Submitted: 15725
Solution: 2647 Topic Description: for a given string (contains only ' z ', ' o ', ' J ' three characters), determine if he can AC.
The rules for AC are as follows:
1. Zoj can ac;
2. If the string form is XZOJX, it can also be AC, where x can be n ' o ' or null;
3. If AZBJC can AC, then Azbojac can also be AC, where a,b,c is n ' o ' or empty; input: input contains multiple sets of test cases, each line has a string containing only ' Z ', ' o ', ' J ' three characters, the string length is less than or equal to 1000. output: for a given string, if you can ac then please output the string "Accepted", otherwise output "wrong Answer". Sample Input:
Zoj
ozojo
ozoojoo
oozoojoooo
zooj
ozojo
oooozojo
zojoooo
Sample output:
Accepted
Accepted
Accepted
Accepted
Accepted
Accepted
wrong Answer
wrong Answer
In fact, the code that can be AC, the sample output is:
#include <stdio.h>
#include <string.h>
char s[1001];
int main ()
{
int num1,num2,num3;
char *p;
while (scanf ("%s", s)!=eof)
{
NUM1 = num2 = num3 = 0;
p = s;
if (!strcmp ("Zoj", s)) {printf ("accepted\n"); continue;}
while ((*p) = = ' O ') {num1++; p++;}
if ((*p) = = ' Z ') {
p++;
while ((*p) = = ' O ') {num2++; p++;}
if ((*p) = = ' J ') {
p++;
while ((*p) = = ' O ') {num3++; p++;}
if (! ( *p) && num2>0 && num3==num1*num2) {printf ("accepted\n"); continue;}
}
}
printf ("Wrong answer\n");
}
return 0;
}
/**************************************************************
problem:1006
user:kirchhoff
Language:c
result:accepted
time:30 Ms
memory:916 KB
**************************************** ************************/