zoukankan      html  css  js  c++  java
  • 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 }
    ---------------- 人们生成的最美好的岁月其实就是最痛苦的时候,只是事后回忆起来的时候才那么幸福。
  • 相关阅读:
    Docker
    CTF各种资源:题目、工具、资料
    Android工具集合
    Android相关资源
    命令注入新玩法:巧借环境攻击目标
    分库分表
    数据库读写分离
    Insomni'hack teaser 2019
    Insomni'hack teaser 2019
    35C3 CTF
  • 原文地址:https://www.cnblogs.com/livelihao/p/5289568.html
Copyright © 2011-2022 走看看