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
");
    else if (s[f[n]]==' ') printf("No
");
    else printf("No comments
");
	return 0;
}


--------

原文地址:https://www.cnblogs.com/cyendra/p/3681531.html