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. String 字符串的追加,数组拷贝

    package chengbaoDemo; import java.util.Arrays; /** *需求:数组的扩容以及数据的拷贝 *分析:因为String的实质是以字符数组存储的,所以字符串的追 ...

  2. hdu 2577 模拟

    #include<stdio.h> #define N 200 char s[N]; int judgeup(char c) { if(c>='A'&&c<=' ...

  3. 百度url 参数详解全

    百度url解析Joe.Smith整理大全 百度url解析Joe.Smith整理大全...1 本文链接:http://blog.csdn.net/qq_26816591/article/details/ ...

  4. C#中的DES加密

    publicstaticstringEncryptString(string sInputString,string sKey,string sIV) { try { byte[] data =Enc ...

  5. spring datasource和mybatis的datasource来源在哪里

    配置一个数据源     spring在第三方依赖包中包含了两个数据源的实现类包,其一是Apache的DBCP,其二是 C3P0.可以在Spring配置文件中利用这两者中任何一个配置数据源.  配置一个 ...

  6. POJ 2111

    记忆化搜索即可,设DP[I][J]为可到达的最大步数. 输出时用了一种较笨拙的方法,还有一种方法是使用最长上升子序列的方式,挺好,先排序,这让我想起上次BESTCODER的一题 #include &l ...

  7. Oracle学习(11):PLSQL程序设计

    PL/SQL程序结构及组成 什么是PL/SQL? •PL/SQL(Procedure Language/SQL) •PLSQL是Oracle对sql语言的过程化扩展 •指在SQL命令语言中添加了过程处 ...

  8. node-webkit 屏幕截图功能

    做 IM 屏幕截图是少不了的,之前 windows 版本是调用的 qq 输入法的截图功能,这个版本又再次尝试自己实现发现是可以的,getusermedia 的权限很高,代码如下 <!DOCTYP ...

  9. JSTL中的常用EL函数(fn:contains(str,subStr))

    转自:https://blog.csdn.net/u012843873/article/details/53289238 ① fn:toLowerCase ④fn:length fn:length函数 ...

  10. [转]C#多线程和线程池

    鸣谢原文:http://www.cnblogs.com/wwj1992/p/5976096.html 1.概念  1.0 线程的和进程的关系以及优缺点 windows系统是一个多线程的操作系统.一个程 ...