2015 多校联赛 ——HDU5334(构造)
Virtual Participation
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 237 Accepted Submission(s): 56
Special Judge
Given an integer K,
she needs to come up with an sequence of integers A satisfying
that the number of different continuous subsequence of A is
equal to k.
Two continuous subsequences a, b are
different if and only if one of the following conditions is satisfied:
1. The length of a is
not equal to the length of b.
2. There is at least one t that at≠bt,
where at means
the t-th
element of a and bt means
the t-th
element of b.
Unfortunately, it is too difficult for Rikka. Can you help her?
The first line contains one integers n (n≤min(K,105)).
The second line contains n space-separated
integer Ai (1≤Ai≤n) -
the sequence you find.
1 2 3 4
假设用1,1...2,2....3,3....来构造,设他们的数量分别为 x y z
则能构成: x + y + z + x*y + y*z + x*z ( x * z 代表三种数都包含的情况)
枚举 x 与 y ,再判断z是否符合 (方法来源:http://blog.csdn.net/oilover/article/details/47164727)
P: 果然还是太弱,完全没想到╮(╯▽╰)╭,慢慢学,慢慢学
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <cmath>
int MAX=0x3f3f3f3f;
using namespace std;
const int INF = 0x7f7f7f;
const int MAXM = 12e4+5;
int ma = 100000; int main()
{ int x,y,z,k;
while(~scanf("%d",&k))
{
if(k == 1)
{
printf("1\n1\n");
continue;
}
if(k == 2)
{
printf("2\n1 1\n");
continue;
}
int flag = 1;
if(k <= 100000)
{
for(int i = 1; i < k; i++)
printf("%d ",1);
printf("1\n");
continue;
}
for(x = 0; x<= 1e5 &&flag ; x++)
for(y = 0; x+y<=1e5 && y <= sqrt(k+0.5) && flag; y++)
{
int t = k - x - y - x*y;
if(t % (x + y + 1) == 0)
{
z = t / (x +y +1);
if(z < 0 || x + y + z > min(k,ma))
continue; int n = x + y + z;
printf("%d\n",n);
for(int i = 1; i <= n; i++)
{
if(i <= x)
printf("1 ");
else
{
if(i <= x + y)
printf("2 ");
else if(i < n)
printf("3 ");
else
printf("3\n");
}
flag = 0;
}
}
}
}
return 0;
}
2015 多校联赛 ——HDU5334(构造)的更多相关文章
- 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 ...
- 2015 多校联赛 ——HDU5294(最短路,最小切割)
Tricks Device Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- 2015 多校联赛 ——HDU5325(DFS)
Crazy Bobo Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Tota ...
- 2015 多校联赛 ——HDU5316(线段树)
Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...
- 2015 多校联赛 ——HDU5323(搜索)
Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- 2015 多校联赛 ——HDU5319(模拟)
Painter Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su ...
- 2015 多校联赛 ——HDU5301(技巧)
Your current task is to make a ground plan for a residential building located in HZXJHS. So you must ...
- 2015 多校联赛 ——HDU5303(贪心)
Delicious Apples Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Other ...
随机推荐
- Java的暑期作业
Java暑期作业 一.<恶意>读书笔记 <恶意>是日本作家东野圭吾写的推理小说之一.看完后不禁为东野先生的奇特的写作手法以及书中所展现的人性的丑恶所震撼.我认为这本书相较< ...
- Python实现栈
栈的操作 Stack() 创建一个新的空栈 push(item) 添加一个新的元素item到栈顶 pop() 弹出栈顶元素 peek() 返回栈顶元素 is_empty() 判断栈是否为空 size( ...
- php后台的在控制器中就可以实现阅读数增加
$smodel=M('Sswz');$smodel->where($map)->setInc('view' ,1);php后台的在控制器中就可以实现阅读数增加前台不需要传值
- TP框架关于模版的使用技巧
1.
- 关于 Form 表单的 enctype 属性
enctype 属性一共有3个值 application/x-www-form-urlencoded 在发送前编码所有字符(默认) multipart/form-data 上传二进制数据, 所以在使用 ...
- Python-字符串及列表操作-Day2
1.数据类型 1.1 变量引出数据类型 变量:用来记录状态变量值的变化就是状态的变化,程序运行的本质就是来处理一系列的变化 1.2 五大基本数据类型: 数字 字符串 列表 元组 字典 1.2.1 数字 ...
- Spring Security入门(1-12)Spring Security 的过滤器机制
Servlet过滤器被用来拦截用户请求来进行请求之前或之后的处理,或者干脆重定向这个请求,这取决于servlet过滤器的功能. Servlet过滤器处理之后的目标servlet是 MVC 分发web ...
- 推荐几个IDEA插件,Java开发者撸码利器。
这里只是推荐一下好用的插件,具体的使用方法不一一详细介绍. JRebel for IntelliJ 一款热部署插件,只要不是修改了项目的配置文件,用它都可以实现热部署.收费的,破解比较麻烦.不过功能确 ...
- shell:正则表达式和文本处理器
1.什么是正则 正则就是用一些具有特殊含义的符号组合到一起(称为正则表达式)来描述字符或者字符串的方法.或者说:正则就是用来描述一类事物的规则. 生活中处处都是正则: 比如我们描述:4条腿 你可能会想 ...
- Hive函数:SUM,AVG,MIN,MAX
转自:http://lxw1234.com/archives/2015/04/176.htm,Hive分析窗口函数(一) SUM,AVG,MIN,MAX 之前看到大数据田地有关于max()over(p ...