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. 【转载】Hyperledger学习小结

    Hyperledger学习小结 自学Hyperledger Composer也有段时间了,是时候对所学的知识总结一下了.因为没有实际项目参与的话,差不多也就到此为止了.后续可能会去了解一下以太坊的技术 ...

  2. [Xcode 实际操作]四、常用控件-(14)使用UIWebView控件加载本地HTML

    目录:[Swift]Xcode实际操作 本文将演示使用网页视图,加载并渲染网页代码. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit im ...

  3. /etc/hosts文件修改后如何生效

    修改/etc/hosts之后正常情况应该是保存之后立即生效的,但是有时不是.使用uname -a 可以查看hostname是多少,就可以知道是否修改生效了.如果没有这时的策略有:1) 重启机器2) 重 ...

  4. mybatis复习01

    1.mybatis的历史: mybatis是apache的一个开源项目,2010被google收购,转移到google code. mybatis是一个优秀的持久层框架,对jdbc操作进行了封装,是操 ...

  5. AT2348 HonestOrUnkind

    传送门 显然\(a>b\)的情况下才有解 考虑先找出一个诚实的人,然后剩下的都可以在\(n\)次以内问出来了 发现如果一个人说另一个人是说谎的那么这两个人必有一个是说谎的,由于诚实的人严格多于不 ...

  6. Jenkins+maven+gitlab+shell实现项目自动化部署

    确认jdk , maven,git这些已经在服务器上搭建成功,gitlab使用的是公司服务也没有进行搭建 下面是jenkins的两种搭建方式 1.      第一种比较简单下载对应jenkins.wa ...

  7. 设置Input标签Date默认值为当前时间

    需求:想设置Imput标签Date默认值为当前时间,通过JavaScript实现. <html> ...... <body> <input type="date ...

  8. ie-"此更新不适应于此电脑"

    cmd-dos命令 expand –F:* C:\update\Windows6.1-KB2533623-x64.msu C:\update\ dism.exe /online /Add-Packag ...

  9. Linux之数据库

    crm 1.一定得会用linux发行版 centos 熟悉各种linux命令 2.你的确保linux服务器可以上网 , 一定得有ip地址,且确保dns解析正常 /etc/resolv.conf 3.上 ...

  10. Jmeter的BeanShell中报错:调用bsh方法时出错Error invoking bsh method: eval

    报错内容:ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval In file: inline evalu ...