Problem : 1014 ( Uniform Generator ) Judge Status : Accepted RunId : 5542633 Language : C++ Author : ssun Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=100000; int main() { int arr[N]; int i,count,j; long step,mod; while(cin>>step>>mod) { arr[0] = 0; for(i=1; i<mod; i++) { arr[i] = (arr[i-1] + step) % mod;//求数组各个值 } sort(arr,arr+mod);//将数组排序,便于比较 bool flag = true; for(i=0; i<mod; i++) { //如果有一个不相等就跳出,并标记为假 if(arr[i] != i) { flag =false; break; } } if(flag) printf("%10d%10d %s\n\n",step,mod,"Good Choice");//注意格式,那里有四个空格 else printf("%10d%10d %s\n\n",step,mod,"Bad Choice"); } return 0; }