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 ...
随机推荐
- lsof/fuser卸载挂载文件
Linux如何卸载挂载文件 在我们进行远程文件操作的时候,我们经常会出现文件服务出现卸载掉哦情况.例如 umount /mnt/net1umount: /mnt/net1: device is b ...
- iOS:地图笔记
地图笔记 01. CLLocation -------------------------------------------------------- CLLocationManager 定位管理者 ...
- 深入理解CommonJS!
CommonJS 一开始大家都认为JS是辣鸡,没什么用,官方定义的API只能构建基于浏览器的应用程序,CommonJS就按耐不住了,CommonJS API定义很多普通应用程序(主要指非浏览器的应用) ...
- CMD/AMD的原理、区别和应用
有必要简单提一下两者的主要区别: 1.CMD推崇依赖就近,可以把依赖写进你的代码中的任意一行,例: define(function(require, exports, module) { var a ...
- 在eclipse上配置tomcat
Eclipse中Tomcat的配置及简单例子 Eclipse中Tomcat的配置是很简单的一个工作,作为一名刚刚起步的编程菜鸟,我将这个配置的过程和简单的例子写下来记录,也希望能给像我怎样的新手一些帮 ...
- cakephp事务处理
使用cakephp框架做开发时,涉及到多个数据表的数据保存,需要使用cakephp的事务处理,查cakephp的说明手册也没看明白,从开发社区中看到了解决的办法,考虑到英文的问题,所以转给大家,以供参 ...
- [Functional Programming] Randomly Pull an Item from an Array with the State ADT (Pair)
Functor composition is a powerful concept that arises when we have one Functor nested in another Fun ...
- PostgreSQL学习资料
我的PostgreSQL学习笔记:http://note.youdao.com/share/?id=2e882717fc3850be9af503fcc0dfe7d0&type=notebook ...
- win10系统怎样手动安装cab更新补丁
win10系统怎样手动安装cab更新补丁 1. 把所有补丁放进一个文件夹 例如 C:\UPDATE2. 以管理员运行命令提示符 3. 输入以下命令後按 Enterdism /online /add-p ...
- pat(B) 1037. 在霍格沃茨找零钱(水题)
代码: #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> ...