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. Tomcat&Servlet

    Tomcat&Servlet 一.web开发相关的概念 1. 软件架构 1.1 C/S架构 C:Client客户端, S:Server服务器 比如:QQ.微信.大型网游 优点: 显示效果炫 安 ...

  2. 误删重要文件怎么办?学会Linux 救援模式再也不担心

    背景 在运用Linux时会出现一些误操作,导致系统无法正常使用,比如删除了某个重要依赖库,或者删除了rpm等等.在这里记录下具体的操作步骤,供以后参考. 意义 学会在使用Linux系统出现误删除系统重 ...

  3. webpack分包:vue单页面解决分包【减少首屏加载时间】--按需加载[路由懒加载]

    1.使用webpack中的syntax-dynamic-import 插件 npm install --save-dev babel-plugin-syntax-dynamic-import 2.配置 ...

  4. Linux如何用查看域名解析

    方法/步骤     查看本地dns配置.确保能上网,dns配置正确.可以查看网卡配置文件和dns配置文件,网卡里配置优先.   ping命令.第一行会返回域名及解析的ip.   host命令.会返回域 ...

  5. Tomcat从socket到java Servlet

    整体架构图 一. 启动阶段 BootStrap的main方法加载server.xml配置文件,封装成Server,Service,Connector,Engine等java对象 Server初始化== ...

  6. 关闭异常进程bat格式文件

    当电脑反应慢可能时某些进程运行导致,可将进程名称添加至bat文件中,形成脚本,快速关闭 操作方法:新建*.txt文件,将进程名以如下方式,添加至文件中,保存并修改文件名称为“*.bat”,window ...

  7. 016 3Sum Closest 最接近的三数之和

    Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...

  8. spring MVC之注解开发控制器(二)

    开发表单控制器 在传统的Spring MVC开发方法中,是通过扩展SimpleFormController类来创建简单的表单控制器.这样就定义了基本的表单处理流程,并允许通过覆盖几个生命周期方法来定制 ...

  9. 如何在数据库中导入excel文件内的数据

    如何在数据库中轻松导入excel格式的文件 1)打开sql server,找到要导入数据的数据库,右键>>任务>>导入数据 2)按照图示选择要导入的excel 3)选择导入到哪 ...

  10. 自动布局库--Masonry使用

    参考资料(戳这里): >  Masonry官网 >  Masonry介绍与使用实践(快速上手Autolayout) >  iOS 开发实践之 Auto Layout >  Ma ...