virtual hust 2013.6.20 数论基础题目 E - Uniform Generator

题目:Uniform Generator

思路:因为这样的一个循环的取模总会出现循环节,所以只需要判断step和mod是否互质

 

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;
int step,mod;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    while(scanf("%d%d",&step,&mod)!=EOF)
    {
        printf("%10d%10d    ",step,mod);
        if(gcd(step,mod)==1)
            printf("Good Choice\n");
        else
            printf("Bad Choice\n");
        printf("\n");
    }
    return 0;
}
View Code

 

posted @ 2013-06-20 19:30  over_flow  阅读(195)  评论(0编辑  收藏  举报