hdu5334(2015多校4)--Virtual Participation(构造)
题目链接: pid=5334">点击打开链接
题目大意:给出一个数字k,要求做出一个长度小于等于10^5的序列。该序列中不同样的连续子序列有k个。
构造啊,。,,,,一点辙都没有
使用连续的数字做成序列,能够省事的计算出不同样的子序列有多少个。
使用n个1,那么不同样子序列有n种。
使用n个1和m个2,那么不同样的子序列有n+m+n*m种。
使用n个1,m个2和l个3,那么不同样的子序列有n+m+l+n*m+n*l+m*l种。
当k小于等于10^5时。直接输出k个1。
当k大于10^5时。对于使用1,2,3的情况能够做出满足各种k的子序列。
那么我们要求的就是求出n。m。l的值,
令a = n+l+1 , b = m+l+1 , c = l ; 得到a,b是为了凑出n+m+l+n*m+n*l+m*l,终于a*b = k + c*c + c + 1
枚举c。求k+c*c+c+1的全部约数。看是否有a和b满足a = n+l+1 , b = m+l+1 , c = l 而且n+m+l <= 10^5
假设存在了就输出连续的n个1,m个2,l个3.
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
#define LL __int64
int main() {
LL k , a , b , c ;
LL i , j , l , flag ;
while( scanf("%I64d", &k) != EOF ) {
if( k <= 100000 ) {
printf("%I64d\n", k) ;
for(i = 1 ; i < k ; i++)
printf("1 ") ;
printf("1\n") ;
continue ;
}
l = flag = 0 ;
while( 1 ) {
c = k+l*l+l+1 ;
for(j = l+1 ; j*j <= c ; j++) {
a = j ;
if( c%a ) continue ;
b = c/a ;
if( b < l+1 ) continue ;
if( a-l-1+b-l-1+l <= 100000 ) {
flag = 1 ;
break ;
}
}
if( flag ) break ;
l++ ;
}
printf("%I64d\n", a+b-l-2) ;
for(i = 0 ; i < a+b-l-2 ; i++) {
if( i < a-l-1 )
printf("1") ;
else if( i < a+b-2*l-2 )
printf("2") ;
else
printf("3") ;
if( i == a+b-l-3 ) printf("\n") ;
else printf(" ") ;
}
}
return 0 ;
}
hdu5334(2015多校4)--Virtual Participation(构造)的更多相关文章
- 2015 多校联赛 ——HDU5302(构造)
Connect the Graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 2015 多校联赛 ——HDU5353(构造)
Each soda has some candies in their hand. And they want to make the number of candies the same by do ...
- hdu5301(2015多校2)--Buildings(构造)
Buildings Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- 2015 多校联赛 ——HDU5334(构造)
Virtual Participation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- 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/Ot ...
- hdu 5288||2015多校联合第一场1001题
pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...
- hdu5379||2015多校联合第7场1011 树形统计
pid=5379">http://acm.hdu.edu.cn/showproblem.php? pid=5379 Problem Description Little sun is ...
- 记人生中第一场认真打的CF——CF1000(虽然是Virtual participation)
老师说下午要让我们(来自开明的新高一同学)感受一下CF,于是下午2:20我们就集中到了机房.老师教我们用Educational Codeforces Round 46 (Rated for Div. ...
- 2015多校联合训练赛 hdu 5308 I Wanna Become A 24-Point Master 2015 Multi-University Training Contest 2 构造题
I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 ...
随机推荐
- Android Design Support Library介绍之:环境搭建
在2015年的GoogleIO大会上.具体的Material Design设计规范出炉了.全新的Android Design Support Library 格.更让人开心的是,这些很酷的风格能够通过 ...
- (原创)sklearn中 F1-micro 与 F1-macro区别和计算原理
最近在使用sklearn做分类时候,用到metrics中的评价函数,其中有一个非常重要的评价函数是F1值,(关于这个值的原理自行google或者百度) 在sklearn中的计算F1的函数为 f1_sc ...
- https://v2ex.com/t/170386
https://v2ex.com/t/170386 https://cnodejs.org/topic/5566952ad4ca459f5267ac59 https://segmentfault.co ...
- PHP Xdebug调试专题
1.介绍与安装 Xdebug是一个PHP扩展,安装配置好后,可以自动记录运行了哪些函数,用了多少毫秒,从哪个文件运行到哪个文件等等 它记下来的调试信息很详细,对一些复杂程序跟踪调试有很大的辅助效果,能 ...
- 【Docker】MySQL容器因为内存限制启动失败?
参考资料: https://github.com/docker-library/mysql/issues/3 Improving MySQL's default configuration:http: ...
- Spring boot 数据源未配置异常
问题 在使Springboot自动生成的项目框架时如果选择了数据源,比如选择了mysql,生成项目之后,启动会报一下异常: Description: Cannot determine embedded ...
- 动态创建的文本框想要加上jQuery的datepicker功能变成日期选择控件该怎么办?
通常页面输入控件想得到日期选择功能,借助jQuery是这样实现的: 1.载入css和js <script src="jqueryui/jquery-ui.js" type=& ...
- Android自己定义button实现长按功能
Android自己定义button实现长按功能 通过自己定义BUTTON,写一个LongTouchBtn类,在按下的时候运行onTouchEvent事件,通过这个事件使用回调函数来实现长按功能! XM ...
- 如何将微信小程序页面内容充满整个屏幕
修改该页面的wxss文件 /* pages/weather/weather.wxss */ .weather{ position: fixed; height: 100%; width: 100%; ...
- (016)给定一个有序数组(递增),敲代码构建一棵具有最小高度的二叉树(keep it up)
给定一个有序数组(递增),敲代码构建一棵具有最小高度的二叉树. 因为数组是递增有序的.每次都在中间创建结点,类似二分查找的方法来间最小树. struct TreeNode { int data; Tr ...