HDU 1014 Uniform Generator

是否能产生不同mod-1个随机数

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 using namespace std;
 5 const int N = 100005;
 6 int main()
 7 {
 8 
 9     freopen("C:\Users\super\Documents\CB_codes\in.txt", "r", stdin);
10     //freopen("C:\Users\super\Documents\CB_codes\out.txt","w",stdout);
11     int step, mod;
12     int mark[N],temp,t_temp;
13     bool suit;
14     while(~scanf("%d%d", &step, &mod) ) {
15         memset(mark, -1, sizeof(mark));
16         suit = true;
17         temp = 0;
18         for(int i = 0; i < mod; i ++) {
19             temp = (temp + step) % mod;
20             if(mark[temp] == 1) {
21                 suit = false;
22                 break;
23             }
24             else {
25                 mark[temp] = 1;
26             }
27         }
28         printf("%10d%10d",step,mod);
29         if(suit) {
30             printf("    Good Choice

");
31         }
32         else {
33             printf("    Bad Choice

");
34         }
35 
36     }
37 
38 
39     fclose(stdin);
40     return 0;
41 }
---------------- 人们生成的最美好的岁月其实就是最痛苦的时候,只是事后回忆起来的时候才那么幸福。
原文地址:https://www.cnblogs.com/livelihao/p/5289568.html