可以暴力求解,求mod次的种子然后统计每个数字出现次数
也可以求是否互质(可以根据hash表的设计来理解互质就能good choice原因)
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int N = 100010;
int vis[N];
int main()
{
int step,mod;
while(cin>>step>>mod)
{
memset(vis,0,sizeof(vis));
int seed = 0;
for(int i=0;i<mod;i++)
{
seed = (seed+step)%mod;
vis[seed] = 1;
}
bool flag = true;
for(int i=1;i<mod;i++)
{
if(!vis[i]) flag = false;
}
if(flag) printf("%10d%10d Good Choice\n",step,mod);
else printf("%10d%10d Bad Choice\n",step,mod);
cout<<endl;
}
}