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; }
本文介绍了一种简单明了的集合判重方法,并通过实例演示如何进行选择判断。
146

被折叠的 条评论
为什么被折叠?



