Why it is giving WA in GUESSTHE .. Can you give me test cases in which it will fail...
include
include
include
int main()
{
char str[21];
int i;
int j;
int l;
long long int no = 1;
scanf("%s", str);
while (strcmp (str , "*"))
{
l = strlen(str);
for (i = l-1 ; i >= 0 ; --i){
if (str[i] == 'Y'){
if (no % (i+1) != 0){
no = no *(i+1);
}
}
}
for (j = 0 ; j < l ; ++j){
if (str[j] == 'N'){
if (no % (j+1) == 0){
no = -1;
break;
}
}
}
printf("%lld\n", no);
scanf("%s", str);
no = 1;
}
return 0;
}
Question link :-- spoj.com/problems/GUESSTHE/
Thnx in advance...!!!