题目:http://acm.hdu.edu.cn/showproblem.php?pid=1014
seed(x+1) = [seed(x) + STEP] % MOD
给出temp和mode,看是否能产生0-mode-1的所有数。输出要求temp和mode占10个字节位置。
思路:给一个种子0,然后执行mode-1次,看是否能产生1~mode-1中所有数。输出格式用%10d.
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int step, mode;
int a[100005];
while (~scanf("%d%d", &step, &mode))
{
int i; bool ans = 0;
memset(a, 0, sizeof(a));
for (i = 1; i < mode; i++)
a[i] = (a[i - 1] + step) % mode;
sort(a, a + mode);
for (i = 0; i < mode; i++)
if (a[i] != i)
ans = 1;
printf("%10d%10d ",step, mode);
if(!ans)
printf("Good Choice\n\n");
else
printf( "Bad Choice\n\n");
}
return 0;
}