K. Perpetuum Mobile
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.
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 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.
4 5
4 2 3 1
5 7
4 2 5 3 1
6 0
1 2 3 4 5 6 其实就是 求n的序列 的逆序对数为k;代码比较简单只是难以想到
#include<iostream>
using namespace std;
int main(){
int n;long long int k;
while(cin>>n>>k){
int flag=n,t=;
for(int i=;i<=n;i++){
if(k>=n-i){
k-=n-i;
cout<<flag--<<" ";
}else{
cout<<t++<<" ";
}
}
cout<<endl;
}
return ;
}
K. Perpetuum Mobile的更多相关文章
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...
- 比赛F-F Perpetuum Mobile
比赛F-F Perpetuum Mobile 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/ ...
- 【判环】Perpetuum Mobile
Perpetuum Mobile 题目描述 The year is 1902. Albert Einstein is working in the patent office in Bern. Many ...
- 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)
A Drawing Borders 很多构造方法,下图可能是最简单的了 代码: #include<bits/stdc++.h> using namespace std; ; struct ...
- 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) Solution
A. Drawing Borders Unsolved. B. Buildings Unsolved. C. Joyride Upsolved. 题意: 在游乐园中,有n个游玩设施,有些设施之间有道路 ...
- gym/101873/GCPC2017
题目链接:https://codeforces.com/gym/101873 C. Joyride 记忆化搜索形式的dp #include <algorithm> #include < ...
- 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)(9/11)
$$2017-2018\ ACM-ICPC\ German\ Collegiate\ Programming\ Contest (GCPC 2017)$$ \(A.Drawing\ Borders\) ...
- thinkphp导入导出excel表单数据
在PHP项目经常要导入导出Excel表单. 先去下载PHPExcel类库文件,放到相应位置. 我在thinkphp框架中的位置为ThinkPHP/Library/Org/Util/ 导入 在页面上传e ...
- Java Magic. Part 3: Finally
Java Magic. Part 3: Finally @(Base)[JDK, magic, 黑魔法] 转载请写明:原文地址 英文原文 系列文章: -Java Magic. Part 1: java ...
随机推荐
- nginx负载 发向代理配置文件参考
来自server+iis linux可做参考 : #user nobody; worker_processes 8; #worker_cpu_affinity 00000001 00000010 0 ...
- Hadoop: the definitive guide 第三版 拾遗 第十章 之Pig
概述: Pig的安装很简单,注意一下几点: 1.设置系统环境变量: export PIG_HOME=.../pig-x.y.z export PATH=$PATH:$PIG_HOME/bin 设置完成 ...
- JavaScript的实现
了解了JavaScript是干什么的< 对一些词的理解 >,下面该知道它是怎么实现的. 一个完整的JavaScript是由三部分组成的,如下图 ECMAScript 可以为不同种类的宿主环 ...
- YII 路由配置
伪静态,通过设置server服务,做域名地址的转换工作. urlManager地址美化,通过程序的方式实现地址美化工作. 通过在主配置文件里配置组件来实现: 'components'=>arra ...
- Codeforces 437C The Child and Toy(贪心)
题目连接:Codeforces 437C The Child and Toy 贪心,每条绳子都是须要割断的,那就先割断最大值相应的那部分周围的绳子. #include <iostream> ...
- C++sort函数使用总结
头文件:algorithm 对于(整数/字符)数组进行比較时,可直接通过sort(a,a+n)或sort(a.begin(),a.end())进行排序,默认升序排列,须要高速实现降序时,有三种方案 1 ...
- sharePoint常用命令
New-SPStateServiceDatabase -Name "StateServiceDatabase" | New-SPStateServiceApplication -N ...
- 【转载】openCV轮廓操作
声明:非原创,转载自互联网,有问题联系博主 1.轮廓的提取 从图片中将目标提取出来,常常用到的是提取目标的轮廓. OpenCV里提取目标轮廓的函数是findContours(), 它的输入图像是一幅二 ...
- 解析stm32的时钟
STM32 时钟系统 http://blog.chinaunix.net/uid-24219701-id-4081961.html STM32的时钟系统 *** http://www.cnblo ...
- 架构漫谈:自己开发一个Log框架
前言 在日常开发中我们常常都会用到写日志的功能,现在网上的写Log的框架有很多,但是对于我个人而言,过于庞大:我们往往只为了使用框架中的某一个功能就不得不引用整个框架. 所以,我们今天就来自己动手开发 ...