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 ...
随机推荐
- GROUP BY 和 ORDER BY 的一起使用
GROUP BY 和 ORDER BY一起使用 写程序也有很长的一段时间了,有些东西我总不曾去思考,很少去积累一些有用的东西,总喜欢"用要即拿"的心态来对待,这是非常不好的坏习惯. ...
- Maven错误-Missing artifact com.sun:tools:jar:1.5.0:system 解决方式
1.Missing artifact com.sun:tools:jar:1.5.0:system Could not resolve dependencies for project com.ifl ...
- Flask + mod_wsgi + Apache on Windows 部署成功(随时接受提问)
前言 说是前言,纯粹就是吐槽. 假设你赶时间.全然能够跳过这部分,我保证不会在这里隐藏不论什么实用的内容. 人上年纪后.可能冲劲不足,我花了大概两周的时间才成功的将flask部署到windows上.还 ...
- 建议53:用状态模式美化代码,关于python-state工具包的理解
在<编写高质量代码:改善python程序的91个建议>的建议53:用状态模式美化代码小节中,介绍了状态模式例如以下:就是当一个对象的内在状态改变时,同意改变其行为,但这个对象看起来 ...
- 【简单的案例分享,停机10分钟】10204升级CRS&DB的PSU至102044
发现一个现象,AIX5.3+HACMP+10.2.0.4RAC+RAW的环境,执行五六年的数据库crsd.log都会报下面错误: ----------------------------------- ...
- OEM:Enterprise Manager 无法连接到数据库实例 错误解决
今天遇到了一个Enterprise Manager 无法连接到数据库实例的错误,无法使用OEM,经过检查发现是 SYSMAN用户被锁定了,关于Enterprise Manager 无法连接到数据库实例 ...
- maven、spring jdbc与mysql、mybatis
以它们之前的一个简单用例作为实例. 一个简单的能跑起来的实例.原文网址.非常好的例子. http://www.open-open.com/lib/view/open1390534380648.html ...
- 如何在maven项目中使用spring
今天开始在maven项目下加入spring. 边学习边截图. 在这个过程中我新建了一个hellospring的项目.于是乎从这个项目出发开始研究如何在maven项目中使用spring.鉴于网上的学习资 ...
- BZOJ 2287 DP+容斥
思路: 先处理出来f[j]表示这i个物品都可用 填满容量j的方案数 容斥一发 处理出来g[j]=g[j-w[i]] 表示i不能用的时候 填满容量j的方案数 //By SiriusRen #includ ...
- 当安装了ubuntu操作系统怎么也调用不出中文输入法时,可以用以下方式尝试解决。
卸载 fcitx sudo apt-get remove fcitx 重启 sudo reboot 重新安装 fcitxsudo apt-get isntall fcitx 安装拼音输入法sudo a ...