2015 多校联赛 ——HDU5334(构造)
来源:互联网 发布:c语音编程招聘 编辑:程序博客网 时间:2024/06/08 12:35
Virtual Participation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 237 Accepted Submission(s): 56
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 subsequencesa, 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 thatat≠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?
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
1. The length of a is not equal to the length of b.
2. There is at least one t that
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 integersn (n≤min(K,105)) .
The second line contains n space-separated integerAi (1≤Ai≤n) - the sequence you find.
The first line contains one integers
The second line contains n space-separated integer
Sample Input
10
Sample Output
41 2 3 4
Author
XJZX
Source
2015 Multi-University Training Contest 4
假设用1,1...2,2....3,3....来构造,设他们的数量分别为 x y z
则能构成: x + y + z + x*y + y*z + x*z ( x * z 代表三种数都包含的情况)
枚举 x 与 y ,再判断z是否符合 (方法来源:http://blog.csdn.net/oilover/article/details/47164727)
P: 果然还是太弱,完全没想到╮(╯▽╰)╭,慢慢学,慢慢学
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <vector>#include <cmath>int MAX=0x3f3f3f3f;using namespace std;const int INF = 0x7f7f7f;const int MAXM = 12e4+5;int ma = 100000;int main(){ int x,y,z,k; while(~scanf("%d",&k)) { if(k == 1) { printf("1\n1\n"); continue; } if(k == 2) { printf("2\n1 1\n"); continue; } int flag = 1; if(k <= 100000) { for(int i = 1; i < k; i++) printf("%d ",1); printf("1\n"); continue; } for(x = 0; x<= 1e5 &&flag ; x++) for(y = 0; x+y<=1e5 && y <= sqrt(k+0.5) && flag; y++) { int t = k - x - y - x*y; if(t % (x + y + 1) == 0) { z = t / (x +y +1); if(z < 0 || x + y + z > min(k,ma)) continue; int n = x + y + z; printf("%d\n",n); for(int i = 1; i <= n; i++) { if(i <= x) printf("1 "); else { if(i <= x + y) printf("2 "); else if(i < n) printf("3 "); else printf("3\n"); } flag = 0; } } } } return 0;}
0 0
- 2015 多校联赛 ——HDU5334(构造)
- 2015 多校联赛 ——HDU5302(构造)
- 2015 多校联赛 ——HDU5353(构造)
- HDU5334(构造,思维)
- hdu5334(2015多校4)--Virtual Participation(构造)
- 2015 多校联赛 ——HDU5289(二分+ST)
- 2015多校联赛 ——HDU5288(数学)
- 2015 多校联赛 ——HDU5299(树删边)
- 2015 多校联赛 ——HDU5305(搜索)
- 2015 多校联赛 ——HDU5303(贪心)
- 2015 多校联赛 ——HDU5301(技巧)
- 2015 多校联赛 ——HDU5319(模拟)
- 2015 多校联赛 ——HDU5323(搜索)
- 2015 多校联赛 ——HDU5316(线段树)
- 2015 多校联赛 ——HDU5325(DFS)
- 2015 多校联赛 ——HDU5335(Walk out)
- 2015 多校联赛 ——HDU5344(水)
- 2015 多校联赛 ——HDU5349(水)
- hdoj 1795 The least one
- Linux下挂载,文件传递,操作规范,文件夹显示大小,网页访问,vim退格,端口查看,查看路由信息等
- "=="与equals,以及equals为ture时hash code是否相同
- 《开源框架那些事儿26》:“最好的模板引擎”Beetl剖析及与Tiny模板引擎对比
- php中php://input、$_POST和$HTTP_RAW_POST_DATA的异同
- 2015 多校联赛 ——HDU5334(构造)
- net.sf.json.JSONObject需要jar包
- Application的生命周期简介
- Java 提取文件编码
- Apache与Nginx的优缺点比较
- phonegap中 app 开发的那些坑~~!!
- hdu 5329 Question for the Leader
- [Github开源库PinterestLikeAdapterView]--Android瀑布流的实现
- 【翻译自mos文章】rman 标准版和企业版的兼容性