Computer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the form

where ``  " is the modulus operator.

Such a function will generate pseudo-random numbers (seed) between 0 and MOD-1. One problem with functions of this form is that they will always generate the same pattern over and over. In order to minimize this effect, selecting the STEP and MODvalues carefully can result in a uniform distribution of all values between (and including) 0 and MOD-1.

For example, if STEP = 3 and MOD = 5, the function will generate the series of pseudo-random numbers 0, 3, 1, 4, 2 in a repeating cycle. In this example, all of the numbers between and including 0 and MOD-1 will be generated every MOD iterations of the function. Note that by the nature of the function to generate the same seed(x+1) every time seed(x) occurs means that if a function will generate all the numbers between 0 and MOD-1, it will generate pseudo-random numbers uniformly with every MODiterations.

If STEP = 15 and MOD = 20, the function generates the series 0, 15, 10, 5 (or any other repeating series if the initial seed is other than 0). This is a poor selection of STEP and MOD because no initial seed will generate all of the numbers from 0 and MOD-1.

Your program will determine if choices of STEP and MOD will generate a uniform distribution of pseudo-random numbers.

Input

Each line of input will contain a pair of integers for STEP and MOD in that order (  ).

Output

For each line of input, your program should print the STEP value right- justified in columns 1 through 10, the MOD value right-justified in columns 11 through 20 and either ``Good Choice" or ``Bad Choice" left-justified starting in column 25. The ``Good Choice" message should be printed when the selection of STEP and MOD will generate all the numbers between and including 0 and MOD-1 when MOD numbers are generated. Otherwise, your program should print the message ``Bad Choice". After each output test set, your program should print exactly one blank line.

Sample Input

3 5
15 20
63923 99999

Sample Output

         3         5    Good Choice

        15        20    Bad Choice

     63923     99999    Good Choice

思路:

若两者互质即为Good Choice,否则为bad,具体可见:https://blog.csdn.net/synapse7/article/details/12210369

但需要注意的是中间的空格是4个,有空行,需要两个回车

AC代码:

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
typedef long long ll;
const int maxn = + ;
const int mods = 1e9 + ; int gcd(int a,int b){
if(b==)return a;
else return gcd(b,a%b);
} int main(){
int s,m;
while(scanf("%d%d",&s,&m)==){
printf("%10d%10d ",s,m);
if(gcd(s,m)==){
printf("Good Choice\n\n");
}else {
printf("Bad Choice\n\n");
}
}
return ;
}

SOJ1022 Uniform Generator的更多相关文章

  1. HDU 1014:Uniform Generator

    Uniform Generator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  2. Uniform Generator 分类: HDU 2015-06-19 23:26 11人阅读 评论(0) 收藏

    Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...

  3. uva 408 Uniform Generator

    Uniform Generator  Computer simulations often require random numbers. One way to generate pseudo-ran ...

  4. HDU 1014 Uniform Generator【GCD,水】

    Uniform Generator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  5. HDU 1014 Uniform Generator(题解)

    Uniform Generator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  6. HDU 1014 Uniform Generator(模拟和公式)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1014 Uniform Generator Time Limit: 2000/1000 MS (Java ...

  7. (杭电 1014)Uniform Generator

    Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...

  8. HDOJ 1014 Uniform Generator(公约数问题)

    Problem Description Computer simulations often require random numbers. One way to generate pseudo-ra ...

  9. 1014 Uniform Generator

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

随机推荐

  1. java SE 入门之运算符(第三篇)

    在 java 中主要有以上运算符,分为 赋值运算符 ,算术运算符.关系运算符(比较运算符),逻辑运算符和三目运算符(三元运算符). 我们一起来学习下吧! 一.赋值运算符 赋值运算符主要有五个.分别是 ...

  2. shell与expect结合使用

    在linux操作系统下,使用脚本自动化,一般由两种方案,方案一:telnet+ftp,方案二:ssh+scp+expect. 以下主要使用ssh+scp+expect为例进行说明使用方式. 第一步:安 ...

  3. JPA注解@GeneratedValue

    @GeneratedValue是JPA的标准用法, JPA提供四种标准用法,由@GeneratedValue的源代码可以看出. public enum GenerationType { TABLE, ...

  4. python学习之老男孩python全栈第九期_day016作业

    1. 请利用filter()过滤出1~100中平方根是整数的数,即结果应该是: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] import math def func( ...

  5. THUSC2017 游记

    你若安好,便是晴天. Day 0 中午就要出发了,上午浮躁的不行,根本写不下题去. 到了火车站之后发现教练和lyc和ztc在4车靠近5车的那一边,然而我在5车靠近4车的那边,尴尬…… 本来是想着上了火 ...

  6. BZOJ1911: [Apio2010]特别行动队(dp 斜率优化)

    题意 题目链接 Sol 裸的斜率优化,注意推导过程中的符号问题. #include<bits/stdc++.h> #define Pair pair<int, int> #de ...

  7. 当div元素内的内容超出其宽度时,自动隐藏超出的内容

    word-break:keep-all;/* 不换行 */ white-space:nowrap;/* 不换行 */ overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */ te ...

  8. opencv3.2.0图像处理之均值滤波blur API函数

    ##.均值滤波:blur函数 ##函数原型 : ,-),int borderType=BORDER_DEFAULT) (参数详解同boxFilter函数) /**********新建Qt控制台程序** ...

  9. Android ListView几个重要属性

    1.transciptMode属性,需要用ListView或者其它显示大量Items的控件实时跟踪或者查看信息,并且希望最新的条目可以自动滚动到可视范围内.通过设置的控件transcriptMode属 ...

  10. java 内存分析之this

    package Demo; /** * this 的值是当前对象的引用 * @author Aaron * */ public class Boy { private int age; public ...