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 ...
随机推荐
- 项目Alpha冲刺Day8
一.会议照片 二.项目进展 1.今日安排 前端界面框架基本完成,剩下侧边栏与权限相关部分未完成.前端路由异常拦截完成.项目结构与开发流程规定完成.后台开发规定小变更. 2.问题困难 组件的拆分与否和组 ...
- 位图(BitMap)
位图 引入:2.给40亿个不重复的无符号整数,没排过序.给一个无符号整数,如何快速判断一个数是否在这40亿个数中. [腾讯] 思路:如果内存够的话,40亿个整型使用位图存储需要500M左右的空间. 分 ...
- verilog学习笔记(1)_两个小module
第一个小module-ex_module module ex_module( input wire sclk,//声明模块的时候input变量一定是wire变量 input wire rst_n,// ...
- pandas 数据分析使用
https://github.com/Erick-LONG/data_analysis/blob/master/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90%20%E9%8 ...
- wpf研究之道——datagrid控件数据绑定
前台: <DataGrid x:Name="TestCaseDataGrid" ItemsSource="{Binding}" > {binding ...
- nyoj Color the fence
Color the fence 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 Tom has fallen in love with Mary. Now Tom w ...
- web信息泄露注意事项
1. 确保您的Web服务器不发送显示有关后端技术类型或版本信息的响应头. 2. 确保服务器打开的端口上运行的所有服务都不会显示有关其构建和版本的信息. 3. 确保所有目录的访问权限正确,保证不会让攻击 ...
- LeetCode & Q28-Implement strStr-Easy
String Two Pointers Description: Implement strStr(). Returns the index of the first occurrence of ne ...
- MySQL中使用sql语句获得表结构
最近在研究PHP,那么就必须涉及到mysql.其中一个功能通过表数据自动生成页面,紧接着发现在一张空表中无法读取数据(因为人家刚刚新建,就是空的没有数据) 延伸出来便是直接查表结构获得字段名,再进行处 ...
- idea的spring boot项目,运行时不要显示在dashboard中
将对应项目的上图配置,取消勾选即可.