您的位置:首页 > 其它

Uniform Generator

2015-07-24 15:02 190 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1014

集合判重简单明了

#include <cstdio>
#include <set>
using namespace std;
set<int> S;
int main()
{
int s,m;
while(scanf("%d%d",&s,&m)!=EOF){
S.clear();
int x=s%m;
S.insert(x);
while(1){
x=(x+s)%m;
if(S.count(x)==1)break;
else S.insert(x);
}
int n=S.size();
if(n!=m)printf("%10d%10d    Bad Choice\n",s,m);
else printf("%10d%10d    Good Choice\n",s,m);
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: