Access to high-quality randomness is very important for many applications, especially in cryptography. Radioactive decay is somtimes used as a source of 搕rue randomness? but this is a fairly slow procedure for getting random numbers. Also, in many applications it is important that the same 搑andom?sequence can be produced in two different places. For these reasons one often uses a pseudo-random sequence instead. A pseudo-random sequence is a sequence that is, in fact, not random, but very hard to distinguish from a truly random sequence. A pseudo-random sequence should also be difficult to predict, i.e., given the first few elements of the sequence it should be difficult do determine some later, yet unseen, number in the sequence.
The Association of Cryptographic Machinery (ACM) has devised an algorithm for generating pseudo-random number sequences, but they have no idea how good it really is.Therefore they want you to test it.
The algorithm to generate a sequence of integers, where each integer is between 0 and B − 1 inclusive, is as follows:
1. Start with any number (the seed) in base B. This number can contain hundreds of base B digits.
2. The last digit (least significant) is output as the next element of the sequence.
3. Create a new number by writing down the sum of all neighbouring digits from left to right. E.g., with B = 10, the number 845 would yield the number 129 (since 8 + 4 = 12 and 4 + 5 = 9).
4. Repeat steps 2 and 3 as many times as needed, or until the number has only one base B digit. You get one more pseudo-random digit between 0 and B − 1 each time.
If we have B = 10 and the seed number is 845, then the next numbers will be 129, 311 (1 + 2 = 3, 2 + 9 = 11), 42 (3 + 1 = 4, 1 + 1 = 2), and 6 (4 + 2 = 6). As 6 is a single digit base 10 number, the algorithm terminates. The pseudo-random digits generated are 5, 9, 1, 2 and 6.
You will be testing the generator as follows. You will be given the first L elements output by the generator and an integer T > L. You are supposed to decide if the first T elements are completely determined by the first L elements. To check the robustness of your testing procedure the ACM have slipped in some impossible sequences, i.e. sequences that cannot be generated by any initial seed.
On the first line of the input is a single positive integer N, telling the number of test cases to follow. The first line of each test case consists of one integer B (2 <= B <= 1 000), the base. The second line consists of an integer L (1 <= L <= 100), followed by the L first elements of some sequence (the elements are written in base 10 and are between 0 and B − 1 inclusive). The third line consists of an integer T, (L < T <= 100 000), the element of the sequence to predict.
For each test case output, on a line of its own:
?搃mpossible?if no seed number can produce the given sequence.
?搖npredictable?if there exists a seed number that produces the given sequence but the first T elements are not completely determined by the first L elements.
?the T:th element of the sequence in base 10, otherwise.
5 5 9 6 7 0
4 11 7 8 4
5 0 1 1 1 0
the first line of the input is a single positive integer N, telling the number of test cases to follow. The first line of each test case consists of one integer B (2 <= B <= 1 000), the base. The second line consists of an integer L (1 <= L <= 100), followed by the L first elements of some sequence (the elements are written in base 10 and are between 0 and B − 1 inclusive). The third line consists of an integer T, (L < T <= 100 000), the element of the sequence to predict.
伪随机数生成算法及比较.pdf 分析了各种常见的伪随机数，并对其特征作了简要描述，并予以比较。 相关下载链接：//download.csdn.net/download/ftblm/5125820?ut
Problem Description Cover is an admin of HOJ, MUT is coming and he needs to generate passwords for every team of MUT. Thus he needs a pesudo-random number generator. As we know, random numbers are usually gernerated by a random number table and a random seed. The random table is an large array. Using random seed to calculate a subscript, we can use the corresponding number in the talbe as a pesudo-random number. But Cover is a geek and he won't do this as others did. He uses a circle array of length N as random table and three numbers ( a, b, c) as random seed. The random nubmer is defined as the product of table[a], table[(a+b-1)%N+1], table[(a+2b-1)%N+1] ... table[c] ( see Sample Input for more details). Of course this product P may be too large, so Cover use P % 1000000007 as the result. Now it's your task, given the table and a query( a, b, c), help Cover find out the pesudo-random number. Input Multiple test cases, at most 20. Process to the end of the file. The first line of input contains three numbers, N, Q, (1 ≤ N ≤ 50000, 1 ≤ Q ≤ 50000) descripting the length of the circle array, the number of queries, and M mentioned above. The second line contains N positive integers less than 10^9, denotes the (1..N)th numbers of the circle array. Then comes Q lines, each line contains three number, means a query of a, b, c ( 1 ≤ a, b, c ≤ N). It's guaranteed that there's an interger i makes c = a + b * i or c + N = a + b * i; Output Print Q lines for each test case, one number per line, which is the pesudo-random number. Sample Input 6 5 1 2 3 4 5 6 1 1 6 1 3 1 1 3 4 2 4 6 3 5 2 Sample Output 720 1 4 12 6
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-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 Each line of input will contain a pair of integers for STEP and MOD in that order (1 <= STEP, MOD <= 100000). 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
- 博客 ajax跨域问题
- 学院 ES6语法详解
- 博客 安装npm报错，安装淘宝镜像cnpm时出现问题及解决方案
- 博客 2021能直接取回皮肤的csgo开箱网站推荐!
- 下载 js 获取中文拼音,Select自动匹配字母获取值的代码
- 学院 2020年新版Java零基础入门视频教程
- 下载 ExtJS 配置和表格控件使用第1/2页
- 学院 FFmpeg4.3开发系列之12：RTSP+Live555直播点播详解
- 学院 Windows脚本bat-文件批处理基础教程
- 下载 柬埔寨行政分界 Level 3
- 博客 T265可以用这种带螺丝固定的USB数据线接，T265上本身也提供了那种螺丝固定的口，因为我不是总是担心接口松动的问题么。
- 学院 玩转MySQL数据库(赠送JDK8新特性)
- 博客 Unity学习记录-Universal RP渲染管道
- 博客 将Nacos默认的derby数据库更换成MySQL排坑
- 博客 Nginx下载和安装
- 下载 word2vec中的数学原理详解
- 下载 直流电机使用PID调速
- 学院 多元线性回归模型的参数与统计量深度解读-基于Python编程复现
- 学院 架构师套餐/JVM/高并发/微服务/Docker等
- 学院 基于SSM框架电影订票网站开发全程实录(附源码)
- 学院 YOLOv5(PyTorch)目标检测实战：Flask Web部署
- 下载 php-5.5.6-Win32-VC11-x64.zip
- 下载 jquery 简单导航实现代码
- 博客 网安上课打卡day01
- 下载 fnt字体打包工具，支持汉字，特殊字符打包
- 学院 Vue.js快速入门