比赛F-F     Perpetuum Mobile

题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/F

题目:

Description

standard input/output Statements

The world famous scientist Innokentiy almost finished the creation of perpetuum mobile. Its main part is the energy generator which allows the other mobile's parts work. The generator consists of two long parallel plates with n lasers on one of them and n receivers on another. The generator is considered to be working if each laser emits the beam to some receiver such that exactly one beam is emitted to each receiver.

It is obvious that some beams emitted by distinct lasers can intersect. If two beams intersect each other, one joule of energy is released per second because of the interaction of the beams. So the more beams intersect, the more energy is released. Innokentiy noticed that if the energy generator releases exactly k joules per second, the perpetuum mobile will work up to 10 times longer. The scientist can direct any laser at any receiver, but he hasn't thought of such a construction that will give exactly the required amount of energy yet. You should help the scientist to tune up the generator.

Input

The only line contains two integers n and k (1 ≤ n ≤ 200000, ) separated by space — the number of lasers in the energy generator and the power of the generator Innokentiy wants to reach.

Output

Output n integers separated by spaces. i-th number should be equal to the number of receiver which the i-th laser should be directed at. Both lasers and receivers are numbered from 1 to n. It is guaranteed that the solution exists. If there are several solutions, you can output any of them.

Sample Input

 

Input
4 5
Output
4 2 3 1
Input
5 7
Output
4 2 5 3 1
Input
6 0
Output
1 2 3 4 5 6

题意:

已知逆序数为k 的序列,求可能序列的情况(只需输出一种即可)。

分析:

观察输入输出可以发现K恰好等于输出序列的逆序数

代码:

 #include<cstdio>
#include<iostream>
using namespace std; int main()
{
int n;
long long k;
while(scanf("%d%I64d",&n,&k)!=EOF)
{
int p=,q=n;
for(int i=;i<=n;i++)
{
if(k>=n-i) //从n开始输出
{
printf("%d ",q--);
k-=n-i;
}
else //不存在逆序数按正序输出
{
printf("%d ",p++);
}
}
printf("\n");
}
return ;
}

比赛的时候没有看懂输入输出的关系,听了汇报之后就明白了。

比赛F-F Perpetuum Mobile的更多相关文章

  1. Codeforces Gym 100187K K. Perpetuum Mobile 构造

    K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...

  2. 【判环】Perpetuum Mobile

    Perpetuum Mobile 题目描述 The year is 1902. Albert Einstein is working in the patent office in Bern. Many ...

  3. K. Perpetuum Mobile

    The world famous scientist Innokentiy almost finished the creation of perpetuum mobile. Its main par ...

  4. 请教下 f = f.replace('\n', '\r')这条没起作用

    !/usr/bin/env python -- coding: utf-8 -- import json import string import sys reload(sys) sys.setdef ...

  5. python中F/f表达式优于format()表达式

    F/f表达式可以解析任意类型的数据 具体实现,看下面示例: 1.解析变量 1 a = 10 3 b = 20 5 res1 = F"a+b的值:{a+b}" 7 print(res ...

  6. F - F HDU - 1173(二维化一维-思维)

    F - F HDU - 1173 一个邮递员每次只能从邮局拿走一封信送信.在一个二维的直角坐标系中,邮递员只能朝四个方向移动,正北.正东.正南.正西. 有n个需要收信的地址,现在需要你帮助找到一个地方 ...

  7. 前序遍历 排序 二叉搜索树 递归函数的数学定义 return 递归函数不能定义为内联函数 f(x0)由f(f(x0))决定

    遍历二叉树   traversing binary tree 线索二叉树 threaded binary tree 线索链表 线索化 1. 二叉树3个基本单元组成:根节点.左子树.右子树 以L.D.R ...

  8. Python格式化字符串(f,F,format,%)

    # 格式化字符串: 在字符串前加上 f 或者 F 使用 {变量名} 的形式来使用变量名的值 year = 2020 event = 'Referendum' value = f'Results of ...

  9. (比赛)B - Super Mobile Charger

    B - Super Mobile Charger Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & ...

随机推荐

  1. why-and-howto-calculate-your-events-per-second

    http://eromang.zataz.com/2011/04/12/why-and-howto-calculate-your-events-per-second/

  2. Google浏览器调试js

    1.进入source找到js位置 一般js文件就到js目录下找,tpl中的就到tpl中找. 我这次写在tpl中的,就到list中找,它就把list中的js单独显示出来了. 2.设置断点,进行排错.刷新 ...

  3. JAVA学习第一课(初识JAVA)

    PS:退ACM集训队了,自己也疯玩了两天,后天就开学了,就正式大二了,该收收心好好学习啦                                                         ...

  4. cc150:实现一个算法来删除单链表中间的一个结点,仅仅给出指向那个结点的指针

    实现一个算法来删除单链表中间的一个结点,仅仅给出指向那个结点的指针. 样例: 输入:指向链表a->b->c->d->e中结点c的指针 结果:不须要返回什么,得到一个新链表:a- ...

  5. Web Service 入门例子

    在网上很常见的一个列子,实现计算器,看完总得自己练练,不然一段时间不接触又忘了 新建一个空网页,因为.net framework 4.0 不能直接建web 服务,只能在项目中添加 然后在项目中添加We ...

  6. 网络编程——TCP连接

    TCP在双方传输数据前,发送方先请求建立连接,接收方同意建立连接后才能传输数据.(打电话:先拨号,等对方同意接听后,才能交流)...高可靠性 UDP不需要建立连接(发短信).不可靠,可能出现数据丢失等 ...

  7. iptables 简单配置

    通过命令 netstat -tnl 可以查看当前服务器打开了哪些端口  Ssh代码   netstat -tnl     查看防火墙设置  Ssh代码   iptables -L -n      开放 ...

  8. select标签操作大全

    http://blog.csdn.net/hhhh2012/article/details/8610336

  9. PGA_AGGREGATE_TARGET 原理

    PGA_AGGREGATE_TARGET参数的理解 PGA结构图:                                   在Oracle9i之前,PGA的计算和控制都是比较复杂的事情,从 ...

  10. codeforces 400E. Inna and Binary Logic 线段树

    题目链接 给出n个数, 定义a[1][i]为这初始的n个数, 然后a[i][j] = a[i-1][j]&a[i-1][j-1], 这样就可以得到一个三角形一共n*(n-1)/2个数. 给出一 ...