URAL 1098 Questions 约瑟夫环

--------

int n;
int f[maxn];
char s[maxn];
int main(){
    int n=0;
    while (gets(s+n)){
        n=strlen(s);
    }
    s[n]=0;
    f[0]=0;
    for (int i=1;i<=n;i++) f[i]=(f[i-1]+1999)%i;
    if (s[f[n]]=='?') printf("Yes\n");
    else if (s[f[n]]==' ') printf("No\n");
    else printf("No comments\n");
	return 0;
}


--------

posted on 2014-01-09 00:54  电子幼体  阅读(116)  评论(0编辑  收藏  举报

导航