传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1014 Uniform Generator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33120    Accepted Submission(s): 13137 Problem Description Computer simulati…
Uniform Generator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 29336    Accepted Submission(s): 11694 Problem Description Computer simulations often require random numbers. One way to generat…
Uniform Generator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 24381    Accepted Submission(s): 9642 Problem Description Computer simulations often require random numbers. One way to generat…
Uniform Generator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 32990    Accepted Submission(s): 13081 Problem Description Computer simulations often require random numbers. One way to generat…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1014 题目意思:给出 STEP 和 MOD,然后根据这个公式:seed(x+1) = [seed(x) + STEP] % MOD,问是否在一个周期里可以产生 0 - mod-1 的数.可以的话输出 "Good Choice", 否则输出 "Bad Choice". 好久以前留下来的问题了,以前觉得题目意思又长,以为是很难的题目......今天看<短码之美>…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1014 解题思路: 1. 把题目意思读懂后,明白会输入两个数,然后根据题中的公式产生一系列伪随机数,看这些数是不是能够包含0~MOD-1.如果产生不了就输出“Good Choice”,否则输出“Bad Choice”. 2. 全部假使x从0开始,设STEP为a,MOD为b.如果说a,b存在倍数关系,即假设最小存在2倍关系,那么就会有b=2a.x初始为0,第一步之后为a,第二步之后为0,之后a.0交替出…
#include<iostream> #include <cstdio> #include <cstring> using namespace std; int main(void) { int s,m,i; /*int seed=0; int a[10005]={0}; //memset(a,0,sizeof(a));*/ while(scanf("%d%d",&s,&m)!=EOF); { int seed=0; int a[10…
找到规律之后本题就是水题了.只是找规律也不太easy的.证明这个规律成立更加不easy. 本题就是求step和mod假设GCD(最大公约数位1)那么就是Good Choice,否则为Bad Choice 为什么这个结论成立呢? 由于当GCD(step, mod) == 1的时候.那么第一次得到序列:x0, x0 + step, x0 + step-- 那么mod之后,必定下一次反复出现比x0大的数必定是x0+1,为什么呢? 由于(x0 + n*step) % mod. 且不须要考虑x0 % mo…
摘取于http://blog.csdn.net/kenden23/article/details/37519883: 找到规律之后本题就是水题了,不过找规律也不太容易的,证明这个规律成立更加不容易. 本题就是求step和mod如果GCD(最大公约数位1)那么就是Good Choice,否则为Bad Choice 为什么这个结论成立呢? 因为当GCD(step, mod) == 1的时候,那么第一次得到序列:x0, x0 + step, x0 + step…… 那么mod之后,必然下一次重复出现比…
http://acm.hdu.edu.cn/showproblem.php?pid=1014 题目的英文实在是太多了 ,搞不懂. 最后才知道是用公式seed(x+1) = [seed(x) + STEP] % MOD 来计算随机数 ,问是否满足随机数. 初级版本: 思路:把所有的用该公式计算出来的数(存在数组中)都遍历出来,然后排序.由于数字是在0 到mod-1 之间,所以数组的下标必然等于数组的值,有一个不等于,就是bad chioce #include <stdio.h> #include…
Problem Description Computer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the form seed(x+1) = [seed(x) + STEP] % MOD where '%' is the modulus operator. Such a function will generate pseudo-…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28661    Accepted Submission(s): 11402 Problem Description Computer simulations often require random numbers. One way to generate pseudo-random nu…
Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 21176 Accepted Submission(s): 8294 Problem Description Computer simulations often require random numbers. One way to generate pseu…
Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 35190 Accepted Submission(s): 14002 Problem Description Computer simulations often require random numbers. One way to generate pseu…
Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26820 Accepted Submission(s): 10629 Problem Description Computer simulations often require random numbers. One way to generate pse…
Uniform Generator  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 an…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5047 解题报告:问一个“M”型可以把一个矩形的平面最多分割成多少块. 输入是有n个“M",现在已经推出这个公式应该是8 * n^2 - 7 * n + 1,但是这个n的范围达到了10^12次方,只要平方一次就超出long long  的范围了,怎么办呢,用大数? 都试过了,很奇怪,会超时,按照估算的话感觉不会,可能是中间结果比较大吧,这个还在思考,但是10^12平方一次乘以八也只达到了10^25次方…
http://acm.hdu.edu.cn/showproblem.php?pid=1014 给出式子seed(x+1) = [seed(x) + STEP] % MOD seed初始为0,给出STEP和MOD的值 问seed能否取到0~(MOD - 1)之间的所有值 简单模拟 # include <stdio.h> int main() { int Step, Mod, i, Seed, Flag[100005]; while(scanf("%d %d",&Ste…
题目链接 http://acm.hdu.edu.cn/search.php?action=listproblem Problem Description Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious.For n given strings S1,S2,⋯,Sn, labelled from 1 to n, you should find the largest i (1≤i≤n) su…
扫雷 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 998    Accepted Submission(s): 289 Problem Description 扫雷游戏是晨晨和小璐特别喜欢的智力游戏,她俩最近沉迷其中无法自拔.该游戏的界面是一个矩阵,矩阵中有些格子中有一个地雷,其余格子中没有地雷. 游戏中,格子可能处于己知和未知的状态…
Car Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25    Accepted Submission(s): 12 Problem Description Ruins is driving a car to participating in a programming contest. As on a very tight sche…
Fraction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Mr. Frog recently studied how to add two fractions up, and he came up with an evil ide…
pid=4831" style="font-weight:normal">题目链接:hdu 4831 Scenic Popularity 题目大意:略. 解题思路:对于休闲区g[i][0]和g[i][1]记录的是近期的两个景点的id(仅仅有一个近期的话g[i][1]为0),对于景点来说.g[i][0]为-1(表示该id相应的是景点),g[i][1]为该景点的热度值.主要就是模拟,注意一些细节就能够了. #include <cstdio> #include &…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5538 Problem Description Have you ever played the video game Minecraft? This game has been one of the world's most popular game in recent years. The world of Minecraft is made up of lots of 1×1×1 blocks…
http://acm.hdu.edu.cn/showproblem.php?pid=4930 就是两个人玩斗地主,有8种牌型,单张,一对,三张,三带一,三带对,四带二,四炸,王炸.问先手能否一次出完牌或者出的第一手牌让对方无牌可出!!能则输出yes. 恶心模拟 8种组合: 1.单牌:一张牌 2.对子:两张相同的牌 3.三重奏(百度翻译出来的..):三张相同的牌 4.三带一:三张相同的带一张牌(大小只考虑前面的牌,不考虑带的) 5.三带二:三张相同的带两张牌,带的两张牌可以一样,也可以不一样(大小…
http://acm.hdu.edu.cn/showproblem.php?pid=4995 给定一维坐标下的n个点,以及每个点的权值,有m次查询,每次将查询的x点上的权值修改为离x最近的k个点权值的平均和,有相同取序号小的.最后输出修改值的总和. 先离线处理出每个x点对应的所有最近的k个点,然后模拟即可 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #inc…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6128 题意:给你n个数,问你有多少对i,j,满足i<j,并且1/(ai+aj)=1/ai+1/aj 在%p意义下. 解法:官方题解说是用二次剩余来解,但是我并不会这玩意了.在网上看到一位大佬没有二次剩余直接通过推公式做出了这题,真是神奇.http://www.cnblogs.com/bin-gege/p/7367337.html  将式子通分化简后可得(ai2+aj2+ai*aj)%p=0 .然后两…
pid=5374">题目链接:hdu 5374 Tetris 模拟.每次进行操作时推断操作是否合法,合法才运行,否则跳过.每次一个token落地,推断一下是否有消除整行. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; /******* Token **********/ const int C[3] = {1, 2, 4}; const int…
ZOJ 3690 题意: 有n个人和m个数和一个k,如今每一个人能够选择一个数.假设相邻的两个人选择同样的数.那么这个数要大于k 求选择方案数. 思路: 打表推了非常久的公式都没推出来什么可行解,好不easy有了想法结果WA到天荒地老也无法AC.. 于是学习了下正规的做法,恍然大悟. 这道题应该用递推 + 矩阵高速幂. 我们设F(n) = 有n个人,第n个人选择的数大于k的方案数: G(n) = 有n个人.第n个人选择的数小于等于k的方案数: 那么递推关系式即是: F(1)=m−k,G(1)=k…
Problem Description Mr. Frog recently studied how to add two fractions up, and he came up with an evil idea to trouble you by asking you to calculate the result of the formula below: As a talent, can you figure out the answer correctly?   Input The f…