Codeforces Gym 100187K K. Perpetuum Mobile 构造
2015-07-18 21:30
561 查看
K. Perpetuum Mobile
Time Limit: 20 SecMemory Limit: 256 MB
题目连接
http://codeforces.com/gym/100187/problem/KDescription
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.
[b]Input[/b]
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.
[b]Output[/b]
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.
[b]Sample Input[/b]
4 5
[b]Sample Output[/b]
4 2 3 1
HINT
[b]题意[/b]
给你n个数,让你构造存在k个逆序数的序列
[b]题解:[/b]
看是否大于n-1,然后大于n-2,就这样一直找下去就好了
[b]代码[/b]
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> #include <stack> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define test freopen("test.txt","r",stdin) #define maxn 200101 #define mod 1000000009 #define eps 1e-9 const int inf=0x3f3f3f3f; const ll infll = 0x3f3f3f3f3f3f3f3fLL; inline ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } //************************************************************************************** ll n,k; int kiss[maxn]; int main() { n=read(),k=read(); int step=1; int flag=n-1; while(flag>=0) { if(k>=flag) { k-=flag; kiss[flag]=step++; } flag--; } for(int i=0;i<n;i++) { if(kiss[i]) printf("%d ",kiss[i]); else printf("%d ",step++); } }
相关文章推荐
- 跟着vamei复习概率论
- android开发之调试技巧 分类: android 学习笔记 2015-07-18 21:30 140人阅读 评论(0) 收藏
- IOS 学习路线
- 面题3 二维数组的查找
- 黑马程序员————Java基础日常笔记---(图形化用户界面)GUI
- 最近在做政务项目,此种项目,本来并不大,主要原因呢,就是要理好业务需要。
- HDU 5285 wyh2000 and pupil (二分图着色)
- AYIT暑假集训大二第一周周三赛 B 跳舞毯
- 号称不会被查水表的通信APP-Telegram
- ACdream 1412 2-3 Trees
- DSAPI之摄像头追踪指定颜色物体
- IOS开发-12.Autoresizing概述
- HUD 4707
- codeforces Gym 100187J J. Deck Shuffling dfs
- jquery动画总结
- ASP.net后台弹出消息对话框的方法!【转】
- 生产者消费者模式(1)
- 【Spark Core】TaskScheduler源码与任务提交原理浅析2
- 10行Java代码实现最近被使用(LRU)缓存
- OpenGL_ES 创建一个平面 绘制纹理 响应输入事件