标签:
http://acm.hdu.edu.cn/showproblem.php?pid=1014
给出式子seed(x+1) = [seed(x) + STEP] % MOD
seed初始为0,给出STEP和MOD的值
问seed能否取到0~(MOD - 1)之间的所有值
简单模拟
# include <stdio.h> int main() { int Step, Mod, i, Seed, Flag[100005]; while(scanf("%d %d",&Step, &Mod) != EOF) { for(i = 0; i <= Mod - 1; i++) Flag[i] = 0; Seed = 0; do { Flag[Seed] = 1; Seed = (Seed + Step) % Mod; } while(Seed != 0); for(i = 0; i <= Mod - 1; i++) if(Flag[i] == 0) break; if(i <= Mod - 1) printf("%10d%10d Bad Choice\n\n", Step, Mod); else printf("%10d%10d Good Choice\n\n", Step, Mod); } return 0; }
标签:
原文地址:http://www.cnblogs.com/linjiaman/p/4463400.html