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 ...
随机推荐
- 一次@value取值失败的原因
网上down了一份源码.启动后报错,通过报错信息定位到这个地方: 之前对这个@Value的实现方式我也没了解过,所以乘机对springboot关于这一块的源码研究了一下.可以参考当时我的一篇分析记录& ...
- 动态创建的文本框想要加上jQuery的datepicker功能变成日期选择控件该怎么办?
通常页面输入控件想得到日期选择功能,借助jQuery是这样实现的: 1.载入css和js <script src="jqueryui/jquery-ui.js" type=& ...
- zStack学习笔记(原创,绝对不是抄的……)
我之前写的文章都没写上面那句,但是这篇写了,主要是因为zStack文章抄袭太严重……故此声明 因为涉及到数据的双向交互问题,所以在这里我考虑使用协议栈来实现数据的收发.首先说下如何在Zstack中添加 ...
- Web前端开发实战1:二级下拉式菜单之CSS实现
二级下拉式菜单在各大学校站点.电商类站点.新闻类站点等大型?站点非经常见,那么它的实现原理是什么呢? 学习了Web前端开发的知识后,我们是能够实现这种功能的.复杂的都是从基础效果上加入做出来的.原理和 ...
- 一个下载git库代码的脚本
由于每日构建需求, 须要用脚本下载代码, 实现自己主动化编译, 这个脚本是整个系统的一小块功能 #!/bin/bash #@author Liuyang #@date 2015-06-23 funct ...
- 【BIEE】17_仪表盘提示中值按顺序显示
我们在使用仪表盘提示的时候,常常会遇到这种问题,客户需要将一些常见的放在最上边,这样方便显示 例如:现在有数据库表如下 我们需要在提示中展示机构名称,我们如下新建提示 展示效果如下: 我们从上图可以看 ...
- 来自oaim的一些推广信息
笔者几年工作经历亲身走访过一些玻璃深加工企业,发现很重要的一种工具装载玻璃的铁架.而许多企业由于缺少实际操作的经验,导致部分铁架从被制作出来就让我们的成品存在质量缺陷的隐患,最常见的是装好中空玻璃,当 ...
- 切换默认Activity和Fragment的动画
Activity中 public void click(View view){ Intent intent = new Intent(); intent.setClass(this, TwoActiv ...
- Android Camera 使用小结。两种方法:一是调用系统camera app,二是自己写camera程序。
源文链接:http://www.cnblogs.com/franksunny/archive/2011/11/17/2252926.html Android Camera 使用小结 Android手机 ...
- php 实现 html转js
[php] <?php function htmltojs($str){ $re=''; $str=str_replace('\','\\',$str); $str=str_replace(&q ...