当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3965:Random Function

题目描述
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.
输入解释
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;
输出解释
Print Q lines for each test case, one number per line, which is the pesudo-random number.
输入样例
6 5
1 2 3 4 5 6
1 1 6
1 3 1
1 3 4
2 4 6
3 5 2
输出样例
720
1
4
12
6
来自杭电HDUOJ的附加信息
Recommend

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3965

最后修改于 2020-10-25T23:08:49+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
12000/4000MS(Java/Others) 32768/32768K(Java/Others)