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 ...
随机推荐
- TensorFlow 版本问题
TensorFlow各个版本均可以在GitHub上下载,之前下载配置的是0.5.0版本,运行的时候,出现很多问题,什么模块缺失attribute,函数参数问题等,修改起来让人抓狂,后来索性下载使用0. ...
- JAVA的基本数据类型和引用数据类型的区别
引用数据类型: 类.接口类型.数组类型.枚举类型.注解类型: 基本数据类型和引用数据类型的区别: 基本数据类型在被创建时,在栈上给其划分一块内存,将数值直接存储在栈上: 引用数据类型在被创 ...
- Quartz.Net 使用心得(一)
最近工作内容与定时任务相关,在实际使用Quartz过程中,有两个小问题较为困扰. 一.多个Trigger如何触发一个Job. 比如上下班打卡时推送消息,上班时间为9:30,打卡提醒时间为9:20较好. ...
- POJ 3709
简单的单调队列优化,注意是哪些点加入队列即可. #include <iostream> #include <cstdio> #include <algorithm> ...
- java中继承关系学习小结
继承:把多个类中同样的内容提取出来.定义到一个类中,其它类仅仅须要继承该类.就能够使用该类公开的属性和公开的方法. 继承的优点:提高代码的复用性.提高代码的可维护性.让类与类之间产生关系,是多态存 ...
- thrift 版本不一致导致 @Override 报错
thrift 版本不一致导致 @Override 报错 学习了:http://blog.csdn.net/antony1776/article/details/78920888 版本不一致导致的: 在 ...
- 微信小程序 多图上传解决方案
为了使代码体积小 我这里将多图上传 封装到单独的一个js 页面的js调用他 我们看firhealth.js文件内容 // pages/home/home.js var upload = requir ...
- nyoj Wythoff Game(暴力枚举)
Wythoff Game ms | KB 描写叙述 近期ZKC同学在学博弈,学到了一个伟大的博弈问题--威佐夫博弈. 相信大家都学过了吧?没学过?没问题.我将要为你讲述一下这个伟大的博弈问题. ...
- 求区间连续不超过K段的最大和--线段树+大量代码
题目描述: 这是一道数据结构题. 我们拥有一个长度为n的数组a[i]. 我们有m次操作.操作有两种类型: 0 i val:表示我们要把a[i]修改为val; 1 l r k:表示我们要求出区间[l,r ...
- edit filter rules in sql source control
https://documentation.red-gate.com/soc6/common-tasks/exclude-objects-using-filters 如果有人上传了filter,nam ...