题目链接:

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(构造)的更多相关文章

  1. 2015 多校联赛 ——HDU5302(构造)

    Connect the Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  2. 2015 多校联赛 ——HDU5353(构造)

    Each soda has some candies in their hand. And they want to make the number of candies the same by do ...

  3. hdu5301(2015多校2)--Buildings(构造)

    Buildings Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Tota ...

  4. 2015 多校联赛 ——HDU5334(构造)

    Virtual Participation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  5. 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 ...

  6. hdu 5288||2015多校联合第一场1001题

    pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...

  7. hdu5379||2015多校联合第7场1011 树形统计

    pid=5379">http://acm.hdu.edu.cn/showproblem.php? pid=5379 Problem Description Little sun is ...

  8. 记人生中第一场认真打的CF——CF1000(虽然是Virtual participation)

    老师说下午要让我们(来自开明的新高一同学)感受一下CF,于是下午2:20我们就集中到了机房.老师教我们用Educational Codeforces Round 46 (Rated for Div. ...

  9. 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 ...

随机推荐

  1. Gitlab系列八之重置管理员密码

    gitlab web登入密码忘记以后可以用如下方式修改密码 [root@gitlat-test gitlab]# gitlab-rails console production Loading pro ...

  2. mongodb权限管理(转)

    Mongodb 预定义角色 Mongodb 中预定义了一些角色,把这些角色赋予给适当的用户上,用户就只能进行角色范围内的操作. 数据库用户角色 (所有数据库都有) read 用户可以读取当前数据库的数 ...

  3. GLSL使用FBO实现MRT(Multiple Render Targets)绘制到多张纹理 【转】

    项目的程序里设计需要将某一帧渲染出来的画面拆成三通道单色图像存到三张纹理里面.要绘制到纹理里,自然就想到FBO了.但是一次要输出多张纹理,这个还没接触过.一阵网上搜索过后,终于了解到了MRT(多重渲染 ...

  4. http://zhidao.baidu.com/link?url=inouJq69pK4PVM2L26fvnxXfRKhJ1uKmttgVqIEqld14SEUa8JzXZfRYHS3qdltqMXBgEQycFsF8AI9DlSoH4_

    http://zhidao.baidu.com/link?url=inouJq69pK4PVM2L26fvnxXfRKhJ1uKmttgVqIEqld14SEUa8JzXZfRYHS3qdltqMXB ...

  5. objc语言的运行时处理

    在Objective-C中,消息是通过objc_msgSend()这个runtime方法及相近的方法来实现的.这个方法需要一个target,selector,还有一些参数.理论上来说,编译器只是把消息 ...

  6. 【微信转载】Google是如何做测试的

    就 目前的软件公司而言,Google无疑是在开放和创新力方面做得最好的.而如何支撑Google这种快速地扩张的研发能力以及迭代速度,并且产品质量总是 一如以往的能给人们很棒的用户体验?这是一个值得我们 ...

  7. Django——META内部类选项

    Django 模型类的Meta是一个内部类,它用于定义一些Django模型类的行为特性.以下对此作一总结: abstract      这个属性是定义当前的模型类是不是一个抽象类.所谓抽象类是不会对应 ...

  8. Linux的fuser命令解析

    fuser命令是用来显示所有正在使用着指定的file, file system 或者 sockets的进程信息. 例一: #fuser –m –u /mnt/usb1 /mnt/usb1: 1347c ...

  9. msbuild,Build failed with Error MSB3073 exited with code 1

    1. 接手以前的老项目,因为项目比较大,所以用Developer Command Prompt 的msbuild命令编译比较快一些,常用命令如下 devenv /?             帮助 ms ...

  10. Mysql查询缓存碎片、缓存命中率及Nagios监控

    Mysql 的优化方案,在互联网上可以查找到非常多资料,今天对Mysql缓存碎片和命中率作了详细了解,个人作了简单整理. 一.Mysql查询缓存碎片和缓存命中率. mysql> SHOW STA ...