6617: Finite Encyclopedia of Integer Sequences

时间限制: 1 Sec  内存限制: 128 MB
提交: 375  解决: 91
[提交] [状态] [讨论版] [命题人:admin]

题目描述

In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.
Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X⁄2)-th (rounded up to the nearest integer) lexicographically smallest one.

Constraints
1≤N,K≤3×105
N and K are integers.

输入

Input is given from Standard Input in the following format:
K N

输出

Print the (X⁄2)-th (rounded up to the nearest integer) lexicographically smallest sequence listed in FEIS, with spaces in between, where X is the total number of sequences listed in FEIS.

样例输入

3 2

样例输出

2 1

提示

There are 12 sequences listed in FEIS: (1),(1,1),(1,2),(1,3),(2),(2,1),(2,2),(2,3),(3),(3,1),(3,2),(3,3). The (12⁄2=6)-th lexicographically smallest one among them is (2,1).

来源/分类

ABC077&ARC084

思路:

1、k为偶数,序列为:k/2、k、k、k.......,共n个数。

2、k为奇数,序列为:(k+1)/2、(k+1)/2、(k+1)/2、(k+1)/2.......再往前推2/n个。

#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[];
int main()
{
scanf("%d%d",&k,&n);
if(k&)
{
for(int i=; i<=n; i++)
a[i]=(k+)/;
int last=n;//以下全是往前推n/2个序列的过程,last表示当前序列的最后一位!
for(int i=; i<=n/; i++)
if(a[last]==) last--;
else
{
a[last]--;
for(int j=last+; j<=n; j++)
a[j]=k;
last=n;
}
for(int i=; i<=last; i++)
printf("%d ",a[i]);
}
else
{
printf("%d ",k/);
for(int i=; i<=n; i++)
printf("%d ",k);
}
return ;
}

Finite Encyclopedia of Integer Sequences(找规律)的更多相关文章

  1. Codeforces450 B. Jzzhu and Sequences (找规律)

    题目链接:https://vjudge.net/problem/CodeForces-450B Jzzhu has invented a kind of sequences, they meet th ...

  2. UVA 11489 - Integer Game(找规律)

    题目链接 #include <cstdio> #include <cstring> #include <string> #include <cmath> ...

  3. CodeForces 450B Jzzhu and Sequences 费波纳茨数列+找规律+负数MOD

    题目:Click here 题意:给定数列满足求f(n)mod(1e9+7). 分析:规律题,找规律,特别注意负数取mod. #include <iostream> #include &l ...

  4. The Cow Lineup_找规律

    Description Farmer John's N cows (1 <= N <= 100,000) are lined up in a row.Each cow is labeled ...

  5. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  6. 计蒜客 39279.Swap-打表找规律 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest L.) 2019ICPC西安邀请赛现场赛重现赛

    Swap There is a sequence of numbers of length nn, and each number in the sequence is different. Ther ...

  7. 暑假集训 #3div2 C Sequence 数字找规律

    C. Sequence (64 Mb, 1 sec / test)Integer sequences are very interesting mathematical objects. Let us ...

  8. hdu4952 Number Transformation (找规律)

    2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...

  9. CF456B Fedya and Maths 找规律

    http://codeforces.com/contest/456/problem/B CF#260 div2 B Fedya and Maths Codeforces Round #260 B. F ...

随机推荐

  1. 如何给自己的开源项目选择和添加 License

    License 的作用:开源 == 为所欲为? 开源并不等于为所欲为! 代码的用途,修改之后的代码有什么要求,开源程序对于原作者的权利和责任等等,都是需要明确的. 开源协议 License 就是这么一 ...

  2. 魔卡少女(cardcaptor)——线段树

    题目 [题目描述] 君君是中山大学的四年级学生.有一天在家不小心开启了放置在爸爸书房中的一本古书.于是,君君把放在书中最上面的一张牌拿出来观摩了一下,突然掀起一阵大风把书中的其她所有牌吹散到各地.这时 ...

  3. msyql分区与分库分表

    分区 工作原理 对用户而言,分区表是一个独立的逻辑表,但是底层MySQL将其分成多个物理子表,这对用户来说是透明的,每一个分区表都会使用一个独立的表文件. 如果数据量比较大,可以进行分区.分区对PHP ...

  4. plpython 中文分词Windows下 PG数据库jieba分词

    windows 下安装版本匹配python-3.4.3.amd64.msipostgresql-10.1-2-windows-x64.exe create language plpython3u;se ...

  5. AtCoder Beginner Contest 115 题解

    题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit ...

  6. springBoot集成web service

    转载大神: https://blog.csdn.net/u011410529/article/details/68063541?winzoom=1 https://blog.csdn.net/nr00 ...

  7. ElasticSearch入门-搜索(java api)

    ElasticSearch入门-搜索(java api) package com.qlyd.searchhelper; import java.util.Map; import net.sf.json ...

  8. c#异步Begininvoke使用随笔

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. 封装一个帮助类来写文件到android外置存储器上

    项目地址:点击打开 项目简介:写文件到android外置存储器的一个帮助类,和它的demo程序 它是如何工作的呢? 1.创建 AppExternalFileWriter 对象并传递context(上下 ...

  10. React:关于在delegate中的confirm或者alert在多次弹出

    如何试验出是delegate的过程就不解说了 直接上解决方案:(当然我的解决方案只适合一定情况) 取比较简单的代码来解说,例如 我一开始使用delegate的原因是由于我有部分html页面是ajax中 ...