Codeforces Round #254 (Div. 2)D(估计)
来源:互联网 发布:腾讯云数据库备份 编辑:程序博客网 时间:2024/05/17 04:35
DZY loves Fast Fourier Transformation, and he enjoys using it.
Fast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if a, b and c are sequences with length n, which are indexed from 0 to n - 1, and
We can calculate c fast using Fast Fourier Transformation.
DZY made a little change on this formula. Now
To make things easier, a is a permutation of integers from 1 to n, and b is a sequence only containing 0 and 1. Given a and b, DZY needs your help to calculate c.
Because he is naughty, DZY provides a special way to get a and b. What you need is only three integers n, d, x. After getting them, use the code below to generate a and b.
//x is 64-bit variable;function getNextX() { x = (x * 37 + 10007) % 1000000007; return x;}function initAB() { for(i = 0; i < n; i = i + 1){ a[i] = i + 1; } for(i = 0; i < n; i = i + 1){ swap(a[i], a[getNextX() % (i + 1)]); } for(i = 0; i < n; i = i + 1){ if (i < d) b[i] = 1; else b[i] = 0; } for(i = 0; i < n; i = i + 1){ swap(b[i], b[getNextX() % (i + 1)]); }}
Operation x % y denotes remainder after division x by y. Function swap(x, y) swaps two values x and y.
The only line of input contains three space-separated integers n, d, x (1 ≤ d ≤ n ≤ 100000; 0 ≤ x ≤ 1000000006). Because DZY is naughty, x can't be equal to 27777500.
Output n lines, the i-th line should contain an integer ci - 1.
3 1 1
132
5 4 2
22455
5 4 3
55554
- Codeforces Round #254 (Div. 2)D(估计)
- codeforces Round # 187(Div.2) D
- Codeforces Round #277 (Div. 2)(D)
- Codeforces Round #291 (Div. 2)(D)
- Codeforces Round #339 (Div. 2) D.Skills(贪心)
- Codeforces Round #232 (Div. 2) D(运算符重载)
- Codeforces Round #244 (Div. 2)D (后缀自动机)
- Codeforces Round #263 (Div. 2)D(树形DP)
- Codeforces Round #264 (Div. 2)D(图论+dp)
- Codeforces Round #265 (Div. 2)D(判断立方体)
- Codeforces Round #266 (Div. 2)D(DP)
- Codeforces Round #269 (Div. 2)D(KMP)
- 线段树(good)Codeforces Round #275 (Div. 2)D
- Hot Days Codeforces Round #132 (Div. 2) D(贪心)
- Codeforces Round #276 (Div. 2)(C贪心,D)
- Codeforces Round #244 (Div. 2)D(字符串DP)
- Codeforces Round #283 (Div. 2)D(good)
- Codeforces Round #285 (Div. 2) (A、B、C、D)
- 基础总结篇之五:BroadcastReceiver应用详解
- 快递查询文档
- gf h小小黄蜂 股份
- 提高网页效率的14条准则
- 在排序数组中,找出给定数字的出现次数
- Codeforces Round #254 (Div. 2)D(估计)
- MFC绘图总结-屏幕截屏,获取DIB/DDB图形Pixel
- 中试简介
- Android 的 数据库 ORM框架 DBExecutor
- 各种排序
- hdu 2199 2899 (二分,三分)
- FindLongest path 某STARTUP 面试题目
- 评测网页效率的工具YSlow
- java的虚拟机工作原理