HDU1014Uniform Generator
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
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.
Input
Output
Sample Input
Sample Output
#include<bits/stdc++.h>
using namespace std; int main() {
int n,m;
while(cin>>n>>m) {
if(__gcd(n,m)==)
printf("%10d%10d Good Choice\n\n",n,m);
else
printf("%10d%10d Bad Choice\n\n",n,m);
}
return ;
}
HDU1014Uniform Generator的更多相关文章
- EasyMesh - A Two-Dimensional Quality Mesh Generator
EasyMesh - A Two-Dimensional Quality Mesh Generator eryar@163.com Abstract. EasyMesh is developed by ...
- 轻量级“集合”迭代器-Generator
Generator是PHP 5.5加入的新语言特性.但是,它似乎并没有被很多PHP开发者广泛采用.因此,在我们了解PHP 7对Generator的改进之前,我们先通过一个简单却显而易见的例子来了解下G ...
- .NET平台开源项目速览(18)C#平台JSON实体类生成器JSON C# Class Generator
去年,我在一篇文章用原始方法解析复杂字符串,json一定要用JsonMapper么?中介绍了简单的JSON解析的问题,那种方法在当时的环境是非常方便的,因为不需要生成实体类,结构很容易解析.但随着业务 ...
- 深入解析js异步编程利器Generator
我们在编写Nodejs程序时,经常会用到回调函数,在一个操作执行完成之后对返回的数据进行处理,我简单的理解它为异步编程. 如果操作很多,那么回调的嵌套就会必不可少,那么如果操作非常多,那么回调的嵌套就 ...
- mybatis Generator生成代码及使用方式
本文原创,转载请注明:http://www.cnblogs.com/fengzheng/p/5889312.html 为什么要有mybatis mybatis 是一个 Java 的 ORM 框架,OR ...
- ABP配套代码生成器(ABP Code Generator)帮助文档,实现快速开发
ABP代码生成器介绍 针对abp这个框架做了一个代码生成器,功能强大.分为两大功能点,一个是数据层,一个是视图层. 数据服务层:通过它,可以实现表设计.领域层初始化.多语言.automapper自动注 ...
- ES6笔记(5)-- Generator生成器函数
系列文章 -- ES6笔记系列 接触过Ajax请求的会遇到过异步调用的问题,为了保证调用顺序的正确性,一般我们会在回调函数中调用,也有用到一些新的解决方案如Promise相关的技术. 在异步编程中,还 ...
- OData Client Code Generator
转发. [Tutorial & Sample] How to use OData Client Code Generator to generate client-side proxy cla ...
- python generator next send
*******oi********oi********oi 上面 * 符号 代表 一系列的代码, oi 代表 一个 [yield]关键字引出的 [数据交换,称之为 oi ] 在一个有[yield] ...
随机推荐
- 带有×的EditText
代码: EditTextWithDel.java(直接复制): package com.sunday.customs; import com.example.customs.R; import and ...
- Vmware下Ubuntu无法上网的问题
本来这个挺简单的个问题,但是由于很久没有使用虚拟机并且期间实体机网络环境发生了一些变化,导致了一些麻烦. 一般用NAT就行了,就是Vmware右下角那个图标(左起第4个)设置就行. 我这么设置了还是不 ...
- 共享内存shared pool (4):Library cache 转储文件
上一篇blog只是从概念上理解Library cache,本篇则是将Library cache从内存中dump出来,看看其结构. 基本命令 ALTER SESSION SET EVENTS 'imme ...
- 一幅图证明chrome的由来和目的
- 转换framebuffer实现安卓截图
编译出了RECOVERY肯定需要截图分享的啦,可是又不能通过DDMS截图~ 那就只好通过提取手机的fb0文件来实现截图. 首先你需要ADB~ 嗯,这个都没有的话你就别看下去了... 还需要ffmpeg ...
- webpack 学习笔记 01 使用webpack的原因
本系列文章实际上就是官网文档的翻译加上自己实践过程中的理解. 伴随着websites演化至web apps的过程,有三个现象是很明显的: 页面中有越来越多的Js. 客户端能做的事情越来越多. 越来越少 ...
- Sqlserver中char,nchar,varchar与Nvarchar的区别分析
1. char类型: 对英文(ASCII)字符占用1个字节,对一个汉字占用2个字节,CHAR存储定长数据很方便,CHAR字段上的索引效率极高,比如定义char(10),那么不论你存储的数据是否达 到了 ...
- SQL1092N The requested command or operation failed because the user ID does not have the authority to perform the requested command or operation.
1.前一天安装号db2后,做了如下处理: ************************************************************ 修改 /etc/sudoers 文件 ...
- 使用工厂bean和Utility Schema定义集合
工厂bean是实现了beanFactory接口的bean,也可以继承AbstractFactoryBean,主要是用于在给定属性参数之后自动创建一个bean对象. 我们在使用基本集合标记定义集合时,不 ...
- Extjs-工具条和菜单 Ext.menu和Ext.Toolbar
转载自:http://blog.csdn.net/itlwc/article/details/7878002 1.创建一个简单工具条效果图 <script type="text/jav ...