2015 Multi-University Training Contest 4 hdu 5334 Virtual Participation
Virtual Participation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 705 Accepted Submission(s): 202
Special Judge
Given an integer K, she needs to come up with an sequence of integers A satisfying that the number of different continuous subsequence of A is equal to k.
Two continuous subsequences a, b are different if and only if one of the following conditions is satisfied:
1. The length of a is not equal to the length of b.
2. There is at least one t that at≠bt, where at means the t-th element of a and bt means the t-th element of b.
Unfortunately, it is too difficult for Rikka. Can you help her?
The first line contains one integers n (n≤min(K,105)).
The second line contains n space-separated integer Ai (1≤Ai≤n) - the sequence you find.
#include <bits/stdc++.h>
using namespace std;
int calc(int k) {
int ret = ;
while(ret*(ret+)/ < k) ++ret;
return ret;
}
int calc2(int x) {
int ret = ;
while(ret*(ret-)/ <= x) ++ret;
return ret-;
}
int main() {
int k;
while(~scanf("%d",&k)) {
if(k <= ) {
printf("%d\n",k);
for(int i = ; i < k; ++i)
printf("1 ");
puts("");
continue; }
int n = calc(k);
int b = n*(n+)/ - k;
int cnt = ,d = ;
printf("%d\n",n);
while(b > ) {
int e = calc2(b);
for(int i = ; i < e; ++i) {
printf("%d%c",d,cnt+==n?'\n':' ');
cnt++;
}
b -= e * (e - ) / ;
d++;
}
for(; cnt < n; ++cnt)
printf("%d%c",d++,cnt+==n?'\n':' ');
}
return ;
}
2015 Multi-University Training Contest 4 hdu 5334 Virtual Participation的更多相关文章
- 2015 Multi-University Training Contest 8 hdu 5390 tree
tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...
- 2015 Multi-University Training Contest 8 hdu 5383 Yu-Gi-Oh!
Yu-Gi-Oh! Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: ...
- 2015 Multi-University Training Contest 8 hdu 5385 The path
The path Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 5 ...
- 2015 Multi-University Training Contest 3 hdu 5324 Boring Class
Boring Class Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- 2015 Multi-University Training Contest 3 hdu 5317 RGCDQ
RGCDQ Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submi ...
- 2015 Multi-University Training Contest 10 hdu 5406 CRB and Apple
CRB and Apple Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- 2015 Multi-University Training Contest 10 hdu 5412 CRB and Queries
CRB and Queries Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Other ...
- 2015 Multi-University Training Contest 6 hdu 5362 Just A String
Just A String Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- 2015 Multi-University Training Contest 6 hdu 5357 Easy Sequence
Easy Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
随机推荐
- spring data JPA 中的多属性排序
在此介绍我所用的一种方式: 第一步,引包 import org.springframework.data.domain.Sort;import org.springframework.data.dom ...
- 使用sdk自带工具uiautomatorviewer查看app控件属性
双击打开即可 其只显示模拟器中的当前页面,所以需要在模拟器中打开你需要的页面,然后刷新
- MYSQL数据的安装、配置
linux安装mysql服务分两种安装方法: 1.源码安装,优点是安装包比较小,只有十多M,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错. 2.使用官方编译好的二进制文件安装,优点是安装 ...
- cocos2D(六)----CCLayer
一个游戏中能够有非常多个场景,每一个场景里面又可能包括有多个图层,这里的图层一般就是CCLayer对象.CCLayer本身差点儿没什么功能.对照CCNode,CCLayer可用于接收触摸和加速计输入. ...
- 使用Swift和SpriteKit写一个忍者游戏
这篇文章的游戏使用SpriteKit和Swift语言来完毕. SpriteKit是苹果自己的游戏引擎,更能贴合iOS系统底层的API,只是架构和实现上都是模仿了Cocos2D.所以使用上事实上区别不大 ...
- java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
http://blog.csdn.net/you23hai45/article/details/70197502
- struts2在action中获取request、session、application,并传递数据
假设仅仅是通过request.session.application传递数据,则不须要获取对应的对象也能够传递数据,代码例如以下: ScopeAction.java: package com.ithe ...
- 三大表连接方式详解之Nested loop join和 Sort merge join
在早期版本,Oracle提供的是nested-loop join,两表连接就相当于二重循环,假定两表分别有m行和n行 如果内循环是全表扫描,时间复杂度就是O(m*n) 如果内循 ...
- Spring《四-一》解决自动装配的问题
自动化装配使得研发减少了响应的指配工作,但是使得响应的检查难以完成. 解决方法: simple模式: <bean autowire="autodetect" dependen ...
- ZBrush破解版真的好用么?
安装ZBrush®的时候是不是经常出现各种奇葩问题,使用ZBrush时候是不是经常出现停止工作状况,究其原因,原来都是破解搞的鬼.ZBrush破解版你还敢用么? 随着国人对版权的重视,越来越多的制作商 ...