hdu 1014传送门、
此题题意看了很久(英语不好是硬伤,只能看些短的)。
题意:给你一个公式,在0到mod-1中按照这个公式生成数字。最后问你是否生成了0-mod-1里面的每一个数。下面贴代码。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
#include <cmath>
#define maxn 100005
using namespace std;
int radom[maxn];
int main()
{
int step,mod;
radom[0] = 0;
while(cin>>step>>mod)
{
for(int i = 1 ; i <= mod-1 ;i++)
{
radom[i] = (radom[i-1] + step)%mod;
}
sort(radom,radom+mod);
bool flag = true;
for(int i = 0 ;i < mod ;i++)
{
if(radom[i]!=i)
{
flag = false;
}
}
cout<<right<<setw(10)<<step;
cout<<right<<setw(10)<<mod;
if(flag)
{
cout<<" Good Choice"<<endl<<endl;;
}
else
{
cout<<" Bad Choice"<<endl<<endl;;
}
}
return 0;
}