HDU 1014 Uniform Generator(题解)
Uniform Generator
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 32990 Accepted Submission(s): 13081
seed(x+1) = [seed(x) + STEP] % MOD
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 MOD values 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 MOD
iterations.
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.
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.
15 20
63923 99999
15 20 Bad Choice
63923 99999 Good Choice
#include<iostream>
#include<cstdio> using namespace std; int gcd(int a, int b)
{
return b == ? a: gcd(b, a % b);
}
int main()
{
int a, b;
while ( cin >> a >> b)
{
printf("%10d%10d ", a, b);
printf(gcd(a, b) == ? "Good Choice": "Bad Choice");
printf("\n\n");
}
}
所以最后也没看明白题目说什么T^T
HDU 1014 Uniform Generator(题解)的更多相关文章
- HDU 1014 Uniform Generator 题解
找到规律之后本题就是水题了.只是找规律也不太easy的.证明这个规律成立更加不easy. 本题就是求step和mod假设GCD(最大公约数位1)那么就是Good Choice,否则为Bad Choic ...
- HDU 1014 Uniform Generator(模拟和公式)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1014 Uniform Generator Time Limit: 2000/1000 MS (Java ...
- HDU 1014 Uniform Generator【GCD,水】
Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU 1014:Uniform Generator
Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- hdu 1014.Uniform Generator 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1014 题目意思:给出 STEP 和 MOD,然后根据这个公式:seed(x+1) = [seed(x) ...
- HDU 1014 Uniform Generator 欧几里得
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1014 解题思路: 1. 把题目意思读懂后,明白会输入两个数,然后根据题中的公式产生一系列伪随机数,看这 ...
- hdu 1014 Uniform Generator 数论
摘取于http://blog.csdn.net/kenden23/article/details/37519883: 找到规律之后本题就是水题了,不过找规律也不太容易的,证明这个规律成立更加不容易. ...
- HDU 1014 Uniform Generator(最大公约数,周期循环)
#include<iostream> #include <cstdio> #include <cstring> using namespace std; int m ...
- 1014 Uniform Generator ACM
http://acm.hdu.edu.cn/showproblem.php?pid=1014 题目的英文实在是太多了 ,搞不懂. 最后才知道是用公式seed(x+1) = [seed(x) + STE ...
随机推荐
- java之旅_高级教程_java泛型
摘自:http://www.runoob.com/java/java-generics.html JAVA泛型 java泛型(generics)是JDK5中引入的新特性,泛型提供了编译时类型安全检测机 ...
- MySQL 5.6 Index Condition Pushdown
ICP(index condition pushdown)是mysql利用索引(二级索引)元组和筛字段在索引中的where条件从表中提取数据记录的一种优化操作.ICP的思想是:存储引擎在访问索引的时候 ...
- hdu1240/poj2225 BFS广搜的再理解
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/guodongxiaren/article/details/37756347 原题地址 pid=124 ...
- RN NetInfo使用
代码: class NetInfoView extends Component { getNetInfo() { //如果是andorid的程序,需要在xml添加获取网络请求权限 NetInfo.fe ...
- perfmon——使用windows系统自带的性能监视器监控进程信息
第一次使用perfmon监控应用进程的信息,步骤总结如下: 第一部分 性能监视器 1.快捷键Win+R打开运行界面,输入“perfmon”命令后回车即可打开windows的性能监视器 2.点击“性能监 ...
- RzCheckTree基本使用
procedure TForm1.Button1Click(Sender: TObject); var i: Integer; begin //循环读取勾选节点代码及内容 //StateIndex 1 ...
- sed 操作命令
sed介绍 grep 只能过滤文件内容,sed既能过滤文件内容同时还能对文件内容进行修改. sed 算是一种编程语言,它有自己的固定语法. sed是一种行编辑器,sed会在内存中开辟一块独立的空间( ...
- 清空select标签中option选项的3种不同方式
方法一 代码如下:document.getElementById("selectid").options.length = 0; 方法二 代码如下:document.formNam ...
- vue 点击当前的标签,获取当前标签的value值
点击当前的标签,获取当前标签的value值 html <p class="title" v-for="(item, i) in items" :key=& ...
- cnpm与npm的区别
原文地址:https://blog.csdn.net/chi1130/article/details/72773278 npm介绍 说明:npm(node package manager)是nodej ...