标签:freopen name ems ice hdu clu code algorithm set
给你公式seed(x+1) = [seed(x) + STEP] % MOD ,输入step和mod,
问你是否可以从第一项0,算到mod,它们是否都不同
是 good choice 否则 bad choice
枚举过去
#include<iostream>
#include<string.h>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
int a[100010];
int main(){
//freopen("in.txt","r",stdin);
int s,m;
while(cin>>s>>m){
int ans=0;
int cnt=1;
memset(a,0,sizeof(a));
a[0]++;
bool flag=0;
while(1){
if(cnt==m) {
flag=1;
break;
}
ans=(ans+s)%m;
a[ans]++;
if(a[ans]>1) break;
cnt++;
}
printf("%10d%10d",s,m);
if(flag)
cout<<" Good Choice"<<endl<<endl;
else
cout<<" Bad Choice"<<endl<<endl;
}
return 0;
}
标签:freopen name ems ice hdu clu code algorithm set
原文地址:https://www.cnblogs.com/mch5201314/p/9813902.html