zoukankan      html  css  js  c++  java
  • HDU 1014 Uniform Generator

    好久没有刷题了。。。今天一来就碰到个不好解决的,不,应该是自己实力太弱了……

    此题光是理解题意就用了不少时间,理解了以后对于如何判断1到MOD-1的数字全出现又让我恼火了一阵子。。。

     1 #include <stdio.h>
     2 #include <math.h>
     3 
     4 int main(){
     5     int s, m, i;
     6     while(scanf("%d%d",&s,&m) != EOF){
     7         int a[100001] = {0};
     8         int seed = 0;
     9         while(!a[seed]){
    10             a[seed] = 1;
    11             seed = (seed + s) % m;
    12         }
    13         for(i = 0; i < m; i++){
    14             if(a[i] == 0){
    15                 printf("%10d%10d    Bad Choice
    
    ",s,m);
    16                 break;
    17             }
    18         }
    19         if(i == m){
    20             printf("%10d%10d    Good Choice
    
    ",s,m);
    21         }
    22     }
    23     return 0;
    24 }
    Everything will be ok in the end. If it is not ok then it is not the end.
  • 相关阅读:
    python3之datetime模块
    python3之time模块
    前端面试题01
    前端面试题02
    angularjs
    nodejs
    android 报错记录
    android知识点回顾二
    android知识点回顾
    Broadcast广播代码例子
  • 原文地址:https://www.cnblogs.com/shirleytian/p/3250531.html
Copyright © 2011-2022 走看看