D. DZY Loves FFT
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

DZY loves Fast Fourier Transformation, and he enjoys using it.

Fast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if ab 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 ndx.
After getting them, use the code below to generate a and b.

  1. //x is 64-bit variable;
  2. function getNextX() {
  3. x = (x * 37 + 10007) % 1000000007;
  4. return x;
  5. }
  6. function initAB() {
  7. for(i = 0; i < n; i = i + 1){
  8. a[i] = i + 1;
  9. }
  10. for(i = 0; i < n; i = i + 1){
  11. swap(a[i], a[getNextX() % (i + 1)]);
  12. }
  13. for(i = 0; i < n; i = i + 1){
  14. if (i < d)
  15. b[i] = 1;
  16. else
  17. b[i] = 0;
  18. }
  19. for(i = 0; i < n; i = i + 1){
  20. swap(b[i], b[getNextX() % (i + 1)]);
  21. }
  22. }

Operation x % y denotes remainder after division x by y.
Function swap(x, y) swaps two values x and y.

Input

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

Output n lines, the i-th line should contain an integer ci - 1.

Sample test(s)
input
  1. 3 1 1
output
  1. 1
  2. 3
  3. 2
input
  1. 5 4 2
output
  1. 2
  2. 2
  3. 4
  4. 5
  5. 5
input
  1. 5 4 3
output
  1. 5
  2. 5
  3. 5
  4. 5
  5. 4

题意:RT

思路:由于b序列一定仅仅含0或1,那么含0的是没有意义的

            直接for就好了,然后用一个数组is[]记录前多少个b序列为1的位置

            每次要找最大值的时候。假设is[]数组的个数小于一个常数。就枚举is数组

            否则直接从大到小枚举最大值就好了

Codeforces Round #254 (Div. 2)D(预计)的更多相关文章

  1. Codeforces Round 254 (Div. 2)

    layout: post title: Codeforces Round 254 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  2. Codeforces Round #254 (Div. 1) C. DZY Loves Colors 线段树

    题目链接: http://codeforces.com/problemset/problem/444/C J. DZY Loves Colors time limit per test:2 secon ...

  3. Codeforces Round #254 (Div. 1) D - DZY Loves Strings

    D - DZY Loves Strings 思路:感觉这种把询问按大小分成两类解决的问题都很不好想.. https://codeforces.com/blog/entry/12959 题解说得很清楚啦 ...

  4. Codeforces Round #254 (Div. 1) D. DZY Loves Strings hash 暴力

    D. DZY Loves Strings 题目连接: http://codeforces.com/contest/444/problem/D Description DZY loves strings ...

  5. Codeforces Round #254 (Div. 1) C. DZY Loves Colors 分块

    C. DZY Loves Colors 题目连接: http://codeforces.com/contest/444/problem/C Description DZY loves colors, ...

  6. Codeforces Round #254 (Div. 1) A. DZY Loves Physics 智力题

    A. DZY Loves Physics 题目连接: http://codeforces.com/contest/444/problem/A Description DZY loves Physics ...

  7. Codeforces Round #254 (Div. 2) A. DZY Loves Chessboard —— dfs

    题目链接: http://codeforces.com/problemset/problem/445/A 题解: 这道题是在现场赛的最后一分钟通过的,相当惊险,而且做的过程也很曲折. 先是用递推,结果 ...

  8. Codeforces Round #254 (Div. 1) C DZY Loves Colors

    http://codeforces.com/contest/444/problem/C 题意:给出一个数组,初始时每个值从1--n分别是1--n.  然后两种操作. 1:操作 a.b内的数字是a,b内 ...

  9. [题解]Codeforces Round #254 (Div. 2) B - DZY Loves Chemistry

    链接:http://codeforces.com/contest/445/problem/B 描述:n种药品,m个反应关系,按照一定顺序放进试管中.如果当前放入的药品与试管中的药品要反应,危险系数变为 ...

随机推荐

  1. DropDownList SelectedIndexChanged使用

    在asp.net中使用dropdownlist,默认是不会送的,我们想要选中一项然后更改相关的数据,应该吧属性AutoPostback改为true. http://msdn.microsoft.com ...

  2. GDB调试精粹及使用实例

    一:列文件清单 1. List (gdb) list line1,line2 二:执行程序 要想运行准备调试的程序,可使用run命令,在它后面可以跟随发给该程序的任何参数,包括标准输入和标准输出说明符 ...

  3. ZOJ 1825 compoud words

    题目大意:输入一串递增的单词序列,需要找出符合条件的单词递增输出,条件是:将一个单词拆成左右两个单词后,能在输入中找到这两个单词.例如单词 alien,可以拆成 a 和 lien,而输入中刚好同时有a ...

  4. Linux下批量转换文件编码

    find -iname "*.java" -exec enca {} + |grep -v ASCI |grep -v -i utf |awk -F':' '{print $1}' ...

  5. COM组件

    COM组件   COM component(COM组件)是微软公司为了计算机工业的软件生产更加符合人类的行为方式开发的一种新的软件开发技术.在COM构架下,人们可以开发出各种各样的功能专一的组件,然后 ...

  6. BZOJ 3236: [Ahoi2013]作业( 莫队 + BIT )

    莫队..用两个树状数组计算.时间复杂度应该是O(N1.5logN). 估计我是写残了...跑得很慢... ----------------------------------------------- ...

  7. BZOJ 3040: 最短路(road) ( 最短路 )

    本来想学一下配对堆的...结果学着学着就偏了... 之前 kpm 写过这道题 , 前面的边不理它都能 AC .. 我也懒得去写前面的加边了... 用 C++ pb_ds 库里的 pairing_hea ...

  8. oracle11g dataguard 完全手册(转)

    转自:http://www.cnblogs.com/tippoint/archive/2013/04/18/3029019.html 一.前言:   网络上关于dataguard的配置文章很多,但是很 ...

  9. 启用nginx status状态详解

    nginx和php-fpm一样内建了一个状态页,对于想了解nginx的状态以及监控nginx非常有帮助.为了后续的zabbix监控,我们需要先了解nginx状态页是怎么回事. 1. 启用nginx s ...

  10. ASP.NET MVC 5 学习教程:添加视图

    原文 ASP.NET MVC 5 学习教程:添加视图 起飞网 ASP.NET MVC 5 学习教程目录: 添加控制器 添加视图 修改视图和布局页 控制器传递数据给视图 添加模型 创建连接字符串 通过控 ...