比赛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. python练习之list

    请用索引取出下面list的指定元素: # -*- coding: utf-8 -*- L = [ ['Apple', 'Google', 'Microsoft'], ['Java', 'Python' ...

  2. 阿里云ECS每天一件事D5:安装php5.4.34

    原本是想把php和nginx合在一起来说的,不过考虑后,还是分开来做吧,已熟悉的更透彻一些. 1.准备类库 yum install autoconf automake libtool re2c fle ...

  3. 老生常谈--Js继承小结

    一直以来,对Js的继承有所认识,但是认识不全面,没什么深刻印象.于是,经常性的浪费很多时间重新看博文学习继承,今天工作不是特别忙,有幸看到了http://www.slideshare.net/stoy ...

  4. cocos2dx tag和zorder

    当一个渲染对象加入到两外一个渲染对象中时,可以有两个可选参数,一个时tag,一个是order virtual void addChild(CCNode * child); virtual void a ...

  5. Windows Azure 社区新闻综述(#73 版)

    欢迎查看最新版本的每周综述,其中包含有关云计算和 Windows Azure的社区推动新闻.内容和对话. 以下是过去一周基于您的反馈汇集在一起的内容: 文章.视频和博客文章 ·   Windows A ...

  6. docker基础入门之一

    一.概述 1.传统虚拟化技术: 纯软件的虚拟化是通过对于硬件层的模拟从而实现允许运行多个操作系统: 硬件辅助虚拟化需要硬件层面对于虚拟化的支持,类似Intel-VT技术等,具有更高的运行效率: 解决方 ...

  7. Foundation 框架 归档

    一.使用XML属性列表归档 此方法适用于NSString.NSDictionary.NSarray.NSDate.NSnumber,其中atomically参数表示先将字典写入临时备份文件,成功之后, ...

  8. Java 网络编程(四) InetAddress类

    链接地址:http://www.cnblogs.com/mengdd/archive/2013/03/09/2951895.html Java 网络编程(四) InetAddress类 InetAdd ...

  9. Tomcat 启动 Debug模式

    如果debug启动遇到如下错误: ERROR: transport error 202: gethostbyname: unknown host ERROR: JDWP Transport dt_so ...

  10. js函数变量

    局部 JavaScript 变量 在 JavaScript 函数内部声明的变量(使用 var)是局部变量,所以只能在函数内部访问它.(该变量的作用域是局部的). 您可以在不同的函数中使用名称相同的局部 ...