比赛F-F Perpetuum Mobile
比赛F-F Perpetuum Mobile
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/F
题目:
Description
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
4 5
4 2 3 1
5 7
4 2 5 3 1
6 0
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的更多相关文章
- Codeforces Gym 100187K K. Perpetuum Mobile 构造
K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...
- 【判环】Perpetuum Mobile
Perpetuum Mobile 题目描述 The year is 1902. Albert Einstein is working in the patent office in Bern. Many ...
- K. Perpetuum Mobile
The world famous scientist Innokentiy almost finished the creation of perpetuum mobile. Its main par ...
- 请教下 f = f.replace('\n', '\r')这条没起作用
!/usr/bin/env python -- coding: utf-8 -- import json import string import sys reload(sys) sys.setdef ...
- python中F/f表达式优于format()表达式
F/f表达式可以解析任意类型的数据 具体实现,看下面示例: 1.解析变量 1 a = 10 3 b = 20 5 res1 = F"a+b的值:{a+b}" 7 print(res ...
- F - F HDU - 1173(二维化一维-思维)
F - F HDU - 1173 一个邮递员每次只能从邮局拿走一封信送信.在一个二维的直角坐标系中,邮递员只能朝四个方向移动,正北.正东.正南.正西. 有n个需要收信的地址,现在需要你帮助找到一个地方 ...
- 前序遍历 排序 二叉搜索树 递归函数的数学定义 return 递归函数不能定义为内联函数 f(x0)由f(f(x0))决定
遍历二叉树 traversing binary tree 线索二叉树 threaded binary tree 线索链表 线索化 1. 二叉树3个基本单元组成:根节点.左子树.右子树 以L.D.R ...
- Python格式化字符串(f,F,format,%)
# 格式化字符串: 在字符串前加上 f 或者 F 使用 {变量名} 的形式来使用变量名的值 year = 2020 event = 'Referendum' value = f'Results of ...
- (比赛)B - Super Mobile Charger
B - Super Mobile Charger Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
随机推荐
- 服务器是R710常见错误汇总:
报错: E1422 CPU 1 machine check error . power cycle AC 解决方案: 系统 BIOS 已报告机器检查错误.请断开系统的交流电源 10 秒,然后重新启动系 ...
- mysql远程登录权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION; FLUSH PRIVILEGES;
- 腾讯出品的抓包工具Rythem
Mac下一直没有fiddler这样好用的抓包工具,Charles要收费,难免不爽,昨天调研国内项目的时候,看到腾讯开源了一款抓包工具Rythem,试用了一下,基本配置无问题,但是通配符方面不太搞的定. ...
- 九一八-->我逝去的青春
九一八纪念馆 十二年前 30元一张门票 我毫不犹豫掏钱进去参观 你们笑我 钱少人傻 在东北的四年 从2001到2005 每年都感慨这一天 北国的秋色里 警钟长鸣 长鸣声中 有我逝去的青春 如今 三十而 ...
- jquery.cookie用法详细解析,封装的操作cookie的库有jquery.cookie.js
jquery.cookie用法详细解析 需要注意存入cookie前,对数据进行序列化, 得到后在反序列化: 熟练运用:JSON.stringify();和JSON.parse(): 通常分为如下几个步 ...
- localstroge可以在页面间传递数值;
连接地址为:http://4.suancai.sinaapp.com/localstorg/a.html 原理是,a页面设置了sessionstorge,b页面可以访问到; 并且已关闭浏览器,sest ...
- SSD磁盘,CPU居高不下,高并发的情况下,是不是mysql解析器耗费的cpu资源高?
你看看我做的实验,这个user表是300多W纪录,普通磁盘下,消耗时间最多的是Copy to tmp table 0.81秒,当然在ssd下,这个可以减少很多很多的,第二高就是sending data ...
- unity 播放外部视频
摘要: Unity支持的播放视频格式有.mov..mpg..mpeg..mp4..avi和.asf.只需将对应的视频文件拖拽入Project视图即可,它会自动生成对应的MovieTexture对象. ...
- codeforces 609F. Frogs and mosquitoes 二分+线段树
题目链接 F. Frogs and mosquitoes time limit per test 2 seconds memory limit per test 512 megabytes input ...
- codeforces 626E. Simple Skewness 三分
题目链接 给n个数, 让你去掉一些数, 使得剩下的数的平均值-中位数的差值最大. 先将数组排序, 然后枚举每一个数作为中位数的情况, 对于每个枚举的数, 三分它的左右区间长度找到一个平均值最大的情况, ...