poj1597

简单题

View Code
#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cstring>

using namespace std;



#define maxn 100005



int step, mod;

bool vis[maxn];



int generate(int step, int mod)

{

    memset(vis, 0, sizeof(vis));

    int x = 0;

    int ret = 0;

    while (!vis[x])

    {

        vis[x] = true;

        x = (x + step) % mod;

        ret++;

    }

    return ret;

}



int main()

{

//    freopen("t.txt", "r", stdin);

    while (~scanf("%d%d", &step, &mod))

    {

        if (generate(step, mod) == mod)

            printf("%10d%10d    Good Choice\n", step, mod);

        else

            printf("%10d%10d    Bad Choice\n", step, mod);

        puts("");

    }

    return 0;

}

 

你可能感兴趣的:(poj)