2015 Multi-University Training Contest 4(hdu5334 - Virtual Participation)数学
来源:互联网 发布:香港青旅 知乎 编辑:程序博客网 时间:2024/06/14 01:22
Virtual Participation
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:
The length of a is not equal to the length of b.
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 (
Output
For each testcase print two lines.
The first line contains one integers
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
#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<vector>#include<cmath>#include<queue>#include<stack>#include<map>#include<set>#include<algorithm>using namespace std;typedef long long LL;const int maxn=100010;const int maxm=1010;const int MOD=1e9+7;const int INF=0x3f3f3f3f;int K;int len[maxn];int main(){ while(scanf("%d",&K)!=EOF) { if(K<=100000) { printf("%d\n",K); for(int i=1;i<K;i++) printf("%d ",1); printf("1\n"); continue; } int N=ceil((sqrt(8*(LL)K-1)-1)/2); int cnt=0,num=0; LL d=N*N+N-2*K; while(d) { int L=int(sqrt(1+4*d*1.0)+1)/2; len[++num]=L; cnt+=L; d-=(LL)L*(L-1); } printf("%d\n",N); for(int i=1;i<=num;i++) { for(int j=1;j<=len[i];j++) printf("%d ",i); } if(cnt<N) { //减掉相同的剩下的还差的不同的补全 for(int j=1;j<=N-cnt;j++) printf("%d ",num+j); } printf("\n"); } return 0;}
- 2015 Multi-University Training Contest 4(hdu5334 - Virtual Participation)数学
- hdu5334(2015多校4)--Virtual Participation(构造)
- 2015 Multi-University Training Contest 4
- 2015 Multi-University Training Contest 4
- 2015 Multi-University Training Contest 4
- 2015 Multi-University Training Contest 4
- 2015 Multi-University Training Contest 4
- HDU 5288 OO’s Sequence(数学)——2015 Multi-University Training Contest 1
- HDU 5399 Too Simple(数学 + 找规律)——2015 Multi-University Training Contest 9
- 2015 Multi-University Training Contest 4 1001 Olympiad
- hdu 5335 Walk Out (2015 Multi-University Training Contest 4)
- 2015 Multi-University Training Contest 4 -- Walk Out
- 2015 Multi-University Training Contest 4 Walk Out
- 2015 Multi-University Training Contest 4(HDOJ5327、5328、5335、5536)
- hdu 5335 Walk Out 2015 Multi-University Training Contest 4
- hdu 5328 Problem Killer 2015 Multi-University Training Contest 4
- hdu 5327 Olympiad 2015 Multi-University Training Contest 4
- HDU 5289 Assignment (2015 Multi-University Training Contest 1)
- hdoj 4883 TIANKENG’s restaurant
- 55 - 字符流中第一个不重复的字符
- Markdown 语法说明
- js预加载/延迟加载
- 编程之美:第四章 数字之趣 4.10_2数字哑谜和回文
- 2015 Multi-University Training Contest 4(hdu5334 - Virtual Participation)数学
- CSS基础-14CSS盒子模型-内边距
- 优化listview的方法
- 鸟哥的私房菜学习笔记九 关于文件。。。。。
- 【独立开发者er Cocos2d-x实战 013】Cocos2dx 网络编程实战之星座运势
- Best Time to Buy and Sell Stock II
- [二分]poj2976 Dropping tests
- 【剑指Offer面试题】 九度OJ1367:二叉搜索树的后序遍历序列
- hdu网格中有多少个矩形【模拟】