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 ...
随机推荐
- C语言:第0次作业
问题1: 你为什么选择计算机专业?你认为你的条件如何?和这些博主比呢? 感性地讲,高中时意外看到了电影<社交网络>,自那时起就将将马克扎克伯格视为偶像,他天才的智慧和长远的眼光深深吸引了我 ...
- verilog学习笔记(0)
assign赋值语句根本不允许出现在always语句块中 位于begin/end块内的多条阻塞赋值语句是串行执行的; 但是多条非阻塞赋值语句却是并行执行的,这些非阻塞赋值语句都会在其中任何一条语句执行 ...
- python的Virtualenv
Virtualenv 虚拟的 Python 环境(简称 venv) 是一个能帮助你在本地目录安装不同版本的 Python 模块的 Python 环境,你可以不再需要在你系统中安装所有东西就能开发并测试 ...
- Twisted UDP编程技术
实战演练1:普通UDP UDP是一种无连接对等通信协议,没有服务器和客户端概念,通信的任何一方均可通过通信原语直接和其他方通信 1.相对于TCP,UDP编程只需定义DatagramProtocol子类 ...
- 201421123042 《Java程序设计》第6周学习总结
1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图或相关笔记,对面向对象思想进行一个总结. 注1:关键词与内容不求多,但概念之间的联系要清晰 ...
- 201421123042 《Java程序设计》第3周学习总结
#Week03-面向对象入门 1. 本周学习总结 1.1写出你认为本周学习中比较重要的知识点关键词,如类.对象.封装等 本周学习关键词:类,对象,封装,关键词:final,this,statis. 1 ...
- 老板怎么办,我们网站遭到DDoS攻击又挂了?
相信现在正在阅读此文的你,一定听说过发生在上个月的史上最大的DDoS攻击. 美国东部时间2月28日,GitHub在一瞬间遭到高达1.35Tbps的带宽攻击.这次DDoS攻击几乎可以堪称是互联网有史以来 ...
- python之路--day15--常用模块之logging模块
常用模块 1 logging模块 日志级别:Noset (不设置) Debug---(调试信息)----也可用10表示 Info--(消息信息)----也可用20表示 Warning---(警告信息) ...
- PHP环境手动搭建wamp-----Apache+MySQL+PHP
首先下载分别下载Apache+MySQL+PHP. 然后分别解压到文件夹中. 1.安装Apache 1)检查80端口是否占用 说明:apache软件占用80软件,在计算机中一个端口只能被一个软件占用 ...
- thinkphp中定义自己的函数
可以在前台和后台的公共文件夹中common.php中定义自己的函数,这样就可以在控制器中调用,而不需要调用对象了 /** * @name addvtorandp * @author 黄峰1664253 ...