Pseudo-Random Numbers  Computers normally cannot generate really random numbers, but frequently are used to generate sequences of pseudo-random numbers. These are generated by some algorithm, but appear for all practical purposes to be really random…
Pseudo Random Nubmer Sampling https://en.wikipedia.org/wiki/Inverse\_transform\_sampling given a distribution's cumulative distribution function (CDF), generate sample numbers for this distribution. typically based on uniform distribution variable X…
Extracted from Section 17.4 Random Numbers, C++ Primer 5th. Ed. The random-number library generates random numbers through a set of cooperating classes: random-number engines and random-number distribution classes. An engine generates  a sequence of…
我在想还要不要写什么文字.确实不需要太多的文字描述吧. 前奏插一个小话题,之前在网上看到这样的冷笑话(有图的),一个程序猿调试个程序,早上怀疑某某地方的错误,下午怀疑某某地方的错误,晚上怀疑某某地方可能错了,睡觉了还是辗转反侧难以入眠.第二天早上,再看看代码的时候,无意中找到了bug,漏下了逗号“,“,哈哈冷笑话. 我这次也是疏忽了.在一个网站的项目中,用random去生成随机数,作为上传文件的名称.当然在需要用户上传的文件中是不容易遇到这个bug的.但是在做爬虫下载文件也用这个random生成…
题目链接:uva 10712 - Count the Numbers 题目大意:给出n,a.b.问说在a到b之间有多少个n. 解题思路:数位dp.dp[i][j][x][y]表示第i位为j的时候.x是否前面是相等的.y是否已经出现过n.对于n=0的情况要特殊处理前导0,写的很乱.搓死. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using nam…
UVA 10539 - Almost Prime Numbers 题目链接 题意:给定一个区间,求这个区间中的Almost prime number,Almost prime number的定义为:仅仅能整除一个素数. 思路:既然是仅仅能整除一个素数,那么这些数肯定为素数的x次方(x > 1),那么仅仅要先打出素数表,然后在素数表上暴力找一遍就能够了,由于素数表仅仅要找到sqrt(Max),大概100W,然后每一个数找的复杂度为log(n),这样复杂度是能够接受的. 代码: #include <…
Tamref love random numbers, but he hates recurrent relations, Tamref thinks that mainstream random generators like the linear congruent generator suck. That's why he decided to invent his own random generator. As any reasonable competitive programmer…
Generating Gaussian Random Numbers http://www.taygeta.com/random/gaussian.html This note is about the topic of generating Gaussia  pseudo-random numbers given a source of uniform  pseudo-random numbers. This topic comes up more frequently than I woul…
Tamref love random numbers, but he hates recurrent relations, Tamref thinks that mainstream random generators like the linear congruent generator suck. That's why he decided to invent his own random generator. As any reasonable competitive programmer…
题意:给定Z, I, M,  L,根据随机数产生式k=(Z*L+I)%M.但是L表示的是上一个产生的数,比如根据产生式产生了序列{2,5,4,3}那么5是由L=2算来的,4由L=5算来的..第1个所产生的数所需的L由系统给定.那么肯定会产生一个环,到某个位置就会开始产生重复的序列,比如12345345345....求循环中有多少个数(循环节)?(如例是3,分别是345) 思路:因为z i m 都是不变的,当L一定,那么产生的数肯定是一定的,所以只要L有重复出现,那就会从那里开始循环.标记一下所产…