比赛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 & ...
随机推荐
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">的含义
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/x ...
- linux系统性能监控常用命令
一.Linux服务器性能关注点 1)CPU -> load:表示cpu在一段时间内正在处理以及等待处理的任务之和统计信息,简单可理解为cpu正处理的线程数和能同时处理的线程数的比值.一般认为 ...
- Codeforces 123E Maze(树形DP+期望)
[题目链接] http://codeforces.com/problemset/problem/123/E [题目大意] 给出一棵,给出从每个点出发的概率和以每个点为终点的概率,求出每次按照dfs序从 ...
- Juicy Couture_百度百科
Juicy Couture_百度百科 Juicy Couture
- CVT电子集团--笔试部分试题
之前有在网上答了下CVT的网上笔试题,特别把它们都弄下来,答案参考,不一定是对的,有错希望大家能提出来. 1.有关系R和S,R∩S等价于(B) A.S-(R-S) B.R-(R-S) C.( ...
- 访问权限系列一(public/private/protected/default):成员变量
通过两个程序包对自身或互相之间的访问,得到结果.(先编译Test_01,得到class文件,通过Test的集中访问情况) 如下Test.java中内容: package com.java; /* * ...
- C/C++存储区划分
一. 在c中分为这几个存储区1.栈 - 由编译器自动分配释放2.堆 - 一般由程序员分配释放,若程序员不释放,程序结束时可能由OS回收3.全局区(静态区),全局变量和静态变量的存储是放在一块的,初始化 ...
- Android应用开发基础篇(7)-----BroadcastReceiver
链接地址:http://www.cnblogs.com/lknlfy/archive/2012/02/22/2363644.html 一.概述 BroadcastReceiver,意思就是广播信息接收 ...
- (转)Windows重启延迟删除,重命名技术原理
所谓重启延迟删除技术,就是在操作系统启动前删除或者替换文件! 说起重启延迟删除,大家可能都很陌生,但是实际上,该功能已经被各种软件所采用:如安装Windows 补丁程序(如:HotFix.Servic ...
- USACO Seciton 5.4 Canada Tour(dp)
因为dp(i,j)=dp(j,i),所以令i>j. dp(i,j)=max(dp(k,j))+1(0<=k<i),若此时dp(i,j)=1则让dp(i,j)=0.(因为无法到达此状态 ...