HDU 1014 Uniform Generator
题解:模拟。
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int seed[100001]; int main() { int s,m; while(scanf("%d%d",&s,&m) != EOF){ bool flag = true; seed[0] = 0; for(int i=1; i<m; i++){ seed[i] = (seed[i-1]+s)%m; } //排序 sort(seed, seed+m); for(int i=0; i<m; i++){ if(seed[i] != i){ flag = false; break; } } if(flag){ printf("%10d%10d Good Choice\n\n", s, m); }else{ printf("%10d%10d Bad Choice\n\n", s, m); } } return 0; }