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 ...
随机推荐
- tomcat解析之简单web服务器(图)
链接地址:http://gogole.iteye.com/blog/587163 之前有javaeyer推荐了一本书<how tomcat works>,今天晚上看了看,确实不错,第一眼就 ...
- ThinkPHP快捷函数
16个快捷函数用法 1.A() 实例化控制器 格式:[资源://][模块/]控制器A($name,$layer='',$level='')@param string $name 资源地址 @pa ...
- Swift 版本历史记录(关注)
http://numbbbbb.gitbooks.io/-the-swift-programming-language-/content/chapter1/03_revision_history.ht ...
- xcode生成的IOS安装文件的位置
通过xcode生成可以在IOS系统下运行的文件的具体设置: 1.首先,需要有相应的程序,并且在mac下的xcode编译后,能够在模拟器中完美运行. 2.单击xcode,打开Xcode > Pre ...
- 设计模式 ( 十六 ) 观察者模式Observer(对象行为型)
设计模式 ( 十六 ) 观察者模式Observer(对象行为型) 1.概述 一些面向对象的编程方式,提供了一种构建对象间复杂网络互连的能力.当对象们连接在一起时,它们就可以相互提供服务和信息. 通常来 ...
- 分布式文件系统GlusterFS
转自于:http://www.cnblogs.com/zitjubiz/archive/2012/11/30/Distributed_File_System_glusterFS.html Gluste ...
- Hiddenfield控件
本文转自:http://www.cnblogs.com/weicleer/archive/2012/11/26/2788722.html ASP.NET2.0 HiddenField控件(1)2007 ...
- redis安装及数据类型简介(string、list、set、sorted_set、hash)
一:简介: redis国内最大的案例--->新浪微博 memcache:是key-value数据库 数据类型:只支持key value数据 过期策略:支持 持久化:不支持(可以通过三方程序) 主 ...
- 04-UIKit(UINavigationController、NSAttributeString、UIImageView)
目录: 一.UINavigationController导航视图控制器 二.NSAttributeString属性字符串 三.UIImageView图像处理 回到顶部 一.UINavigationCo ...
- 基于visual Studio2013解决C语言竞赛题之0801信息输出
题目