暴力遍历一遍就行啊!坑啊!开始我还以为会超时的啊!
AC代码如下:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
bool mark[100000], flag;
int seed, step, mod;
while( scanf( "%d%d", &step, &mod ) != EOF ){
memset( mark, false, sizeof( mark ) );
seed = 0;
mark[seed] = true;
for( int i = 0; i < mod; i++ ){
seed = ( seed + step ) % mod;
mark[seed] = true;
}
flag = true;
for( int i = 0; i < mod; i++ ){
if( mark[i] != true ){
flag = false;
break;
}
}
if( flag == true ){
printf( "%10d%10d Good Choice\n\n", step, mod );
}else{
printf( "%10d%10d Bad Choice\n\n", step, mod );
}
}
return 0;
}