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

Problem Description
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he asks rikka to have some practice on codeforces. Then she opens the problem B:

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?

 
Input
There are at most 20 testcases,each testcase only contains a single integer K (1≤K≤109)
 
Output
For each testcase print two lines.

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.

 
Sample Input
10
 
Sample Output
4
1 2 3 4
 
Author
XJZX
 
Source
 
解题:
 
 #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的更多相关文章

  1. 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 ...

  2. 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:  ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. [笔记][Java7并发编程实战手冊]系列文件夹

    推荐学习多线程之前要看的书. [笔记][思维导图]读深入理解JAVA内存模型整理的思维导图文章里面的思维导图或则相应的书籍.去看一遍. 能理解为什么并发编程就会出现故障. Java7并发编程实战手冊 ...

  2. centos6安装eclipse

    1. 下载eclipse 我下载的是eclipse-jee-juno-SR2-linux-gtk-x86_64.tar.gz 能够在http://www.eclipse.org/downloads/处 ...

  3. 使用 python 读写中文json

    读写中文json )   输出中文的json. 通过使用 ensure_ascii=False,输出原有的语言文字.indent參数是缩进数量. 更改写文件格式 将上一步导出的 string 直接写文 ...

  4. MFC窗口去边框、置顶、全屏、激活

    静态移除长提边框非常easy,直接设置"Border"属性为"none"就可以 "Maximize Box", "Minimize ...

  5. Nagios监控nginx服务具体过程

    1在nginx 服务器上安装nrpe客户端: Nginx的服务须要监控起来.不然万一down了而不及时修复,会影响web应用.例如以下web应用上面启动的nginx后台进程[root@lb-net-2 ...

  6. VB.NET机房收费系统总结

    总感觉这次机房收费系统非常有份量,一直没有下手总结,从2014-7-27至2014-9-29.这中间有太多故事和成长.首先说一下两次机房收费系统的不同,它是我们从面向过程向面向对象的一个转变.在.NE ...

  7. 什么是EL表达式

    转自:https://blog.csdn.net/hj7jay/article/details/51302466 1. EL表达式主要作用 EL表达式说白了,就是让JSP写起来更加方便,它属于JSP技 ...

  8. mysql授予IP远程访问访问语句

    mysql -u root -p; GRANT ALL PRIVILEGES ON *.* TO '用户名'@'你的IP地址' IDENTIFIED BY '密码' WITH GRANT OPTION ...

  9. 关于 Visual Studio 中文提示的问题

    [转自 https://blog.csdn.net/iloli/article/details/51055299] [转自 http://www.cnblogs.com/hellowin/p/6383 ...

  10. log4j:WARN Please initialize the log4j system properly.解决方案

    在使用quarz任务调度框架时的错误,实际上这个问题很常见,并不影响程序的使用,只是缺少日志输出,完整错误信息: log4j:WARN No appenders could be found for ...