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\n\n");
31         }
32         else {
33             printf("    Bad Choice\n\n");
34         }
35 
36     }
37 
38 
39     fclose(stdin);
40     return 0;
41 }

 

posted @ 2016-03-17 21:40  闪耀子  阅读(123)  评论(0编辑  收藏  举报