ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1098. Questions

Something strange
Posted by Brainfuck 26 May 2005 23:52
Can anyone tell me, why the length of the first dample is 109 but not 108 as in note.


Also. Can you find a mistake in my sol:

#include <cstdio>
#include <cstring>
using namespace std;
char S[30010];
int g(int x,int n)
{
    return (x%n==0)?n:x%n;
}
void main()
{
    for(int i =0; scanf("%c",&S[i])==1;i++);
    int n=strlen(S),k=1999,prev,next;
    next = (k%2 == 0)?1:2;
    if(n==1)
        next = 1;
    for(int i = 3; i<=n;i++)
    {
        prev=next;
        next=g((prev+k%i),i);
    }
    switch(S[next-1])
    {
    case '?':
        printf("Yes");
        break;
    case ' ':
        printf("No");
        break;
    default:
        printf("No comments");
        break;
    }
}