您的位置:首页 > 其它

POJ 1597 Uniform Generator

2011-03-04 20:28 267 查看
根据循环群的知识,step的生成群的周期为n/gcd(step,n),所以,只有当gcd(step,n)=1时,才是一个good choice

代码:

#include<iostream>
#include<cstdio>
#include<memory.h>
using namespace std;
__int64 gcd(__int64 a,__int64 b)
{
if(b==0)
return a;
else
return gcd(b,a%b);
}
int main()
{
__int64 a,b,d;
while(scanf("%I64d%I64d",&a,&b)!=EOF)
{
d=gcd(a,b);
printf("%10I64d%10I64d    ",a,b);
if(d!=1)
printf("Bad Choice/n");
else
printf("Good Choice/n");
printf("/n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: