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

Problem Description
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he asks rikka to have some practice on codeforces. Then she opens the problem B:

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?

 
Input
There are at most 20 testcases,each testcase only contains a single integer K (1≤K≤109)
 
Output
For each testcase print two lines.

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.

 
Sample Input
10
 
Sample Output
4
1 2 3 4
 
Author
XJZX
 
Source

假设用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(构造)的更多相关文章

  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. 2015 多校联赛 ——HDU5294(最短路,最小切割)

    Tricks Device Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To ...

  4. 2015 多校联赛 ——HDU5325(DFS)

    Crazy Bobo Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Tota ...

  5. 2015 多校联赛 ——HDU5316(线段树)

    Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...

  6. 2015 多校联赛 ——HDU5323(搜索)

    Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  7. 2015 多校联赛 ——HDU5319(模拟)

    Painter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Su ...

  8. 2015 多校联赛 ——HDU5301(技巧)

    Your current task is to make a ground plan for a residential building located in HZXJHS. So you must ...

  9. 2015 多校联赛 ——HDU5303(贪心)

    Delicious Apples Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Other ...

随机推荐

  1. 项目Alpha冲刺Day7

    一.会议照片 二.项目进展 1.今日安排 今天都是课,主要就是用空闲时间熟悉一下框架使用以及继续进行框架搭建. 2.问题困难 前台界面框架vue和element-ui的写法要适应. 3.心得体会 vu ...

  2. MySort实验报告

    实验日期:2017.5.2 实验内容:利用sort方法对已给的数据进行重新排序. 实验原图: 对原代码进行添加,补充新的内容: 在for循环中,新输入一个变量j,并新定义新的长度toSort.leng ...

  3. bzoj千题计划244:bzoj3730: 震波

    http://www.lydsy.com/JudgeOnline/problem.php?id=3730 点分树内对每个节点动态维护2颗线段树 线段树以距离为下标,城市的价值为权值 对于节点x的两棵线 ...

  4. 易错点---所有的字符都自带bool值

    所有的字符都自带布尔值,只有0,None,空为False,其他全部为真!!!!!!!!!!! count = 0 while count < 3 : inp_age =input('Enter ...

  5. 一种dubbo逻辑路由方案

    背景介绍 现在很多的公司都在用dubbo.springcloud做为服务化/微服务的开发框架,服务化之后应用越来越多,链路越来越长,服务环境的治理变的很困难.比如:研发团队的人很多的,同时有几个分支在 ...

  6. js判断语句关于true和false后面跟数字或字符串的问题

    我经常在代码中看到很长串判断,看到就头疼,简单的整理一下. 比如:(client.top>=0&&client.left>=0&&client.bottom ...

  7. Spring Security 入门(3-11)Spring Security 的登录密码验证过程 UsernamePasswordAuthenticationFilter

    认证过程如下 一.先判断请求(请求必须是post请求)地址是否为配置的 login-processing-url 值(默认/j_spring_security_check),如果不是,则放行,进入下一 ...

  8. 赛码网算法: 上台阶 ( python3实现 、c实现)

    上台阶 题目描述 有一楼梯共m级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第m级,共有多少走法?注:规定从一级到一级有0种走法. 输入输入数据首先包含一个整数n(1<=n<=1 ...

  9. python KindEditord

    python 文本编辑器(KindEditord) 1.下载 官网下载:http://kindeditor.net/down.php 本地下载:http://files.cnblogs.com/fil ...

  10. Text-鼠标点击事件

    from tkinter import * import webbrowser master=Tk() text=Text(master,width=50,height=20) text.pack() ...