题目链接:

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. 网络流量工具iftop,ifstat

    此文非原创,转自 http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858923.html 介绍 ifstat工具是个网络接口监测工具,比较简单 ...

  2. 46. Permutations 排列数

    46. Permutations 题目 Given a collection of distinct numbers, return all possible permutations. For ex ...

  3. vue-resource基本使用方法

    一.vue-resource特点 1.体积小:vue-resource非常小巧,在压缩以后只有大约12KB,服务端启用gzip压缩后只有4.5KB大小,这远比jQuery的体积要小得多. 2.支持主流 ...

  4. mysql show profiles使用分析sql性能

    mysql show profiles使用分析sql性能 Show profiles是5.0.37之后添加的,要想使用此功能,要确保版本在5.0.37之后. 查看一下我的数据库版本 mysql> ...

  5. es6模块学习总结

    模块功能主要由两个命令构成:export和import. export用于输出对外接口,improt用于输人接口 exprot 可以输出变量,也可以输出函数.类. 输出变量的三种写法 // 写法一ex ...

  6. Genymotion 在win10 下的安装

    首先我在Genymotion官网上并没有找到他的安装程序.据说是在注冊后,通过邮件里的链接下载,结果也没有看到.最后详细在哪下的,忘了收藏.我下的是 genymotion-2.5.3-vbox.exe ...

  7. 谷歌Cartographer学习 -快速安装测试

    参考资料:https://www.cnblogs.com/hitcm/p/5939507.html PC下面进行安装: 遇到的问题如下 1.首先安装ceres solver 在编译的时候,如果是低配的 ...

  8. kvaser leaf light v2 在Linux 下面的使用方法

    一.安装驱动 下载地址: https://www.kvaser.cn/developer-blog/build-install-signed-kvaser-driver-modules/  严格按照操 ...

  9. Keep-Alive简介及在Tomcat中配置

      Keep-Alive功能使客户端到服务器端的连接持续有效,当出现对服务器的后继请求时,Keep-Alive功能避免了建立或者重新建立连接.市场上 的大部分Web服务器,包括iPlanet.IIS和 ...

  10. JPA JPQL 查询、排序.....(转)

    http://macrabbit.iteye.com/blog/855384 JPQL就是一种查询语言,具有与 SQL 相类似的特征, JPQL 是完全面向对象的,具备继承.多态和关联等特性,和hib ...