Finite Encyclopedia of Integer Sequences(找规律)
6617: Finite Encyclopedia of Integer Sequences
时间限制: 1 Sec 内存限制: 128 MB
提交: 375 解决: 91
[提交] [状态] [讨论版] [命题人:admin]
题目描述
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.
输入
K N
输出
样例输入
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).
来源/分类
思路:
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(找规律)的更多相关文章
- Codeforces450 B. Jzzhu and Sequences (找规律)
题目链接:https://vjudge.net/problem/CodeForces-450B Jzzhu has invented a kind of sequences, they meet th ...
- UVA 11489 - Integer Game(找规律)
题目链接 #include <cstdio> #include <cstring> #include <string> #include <cmath> ...
- CodeForces 450B Jzzhu and Sequences 费波纳茨数列+找规律+负数MOD
题目:Click here 题意:给定数列满足求f(n)mod(1e9+7). 分析:规律题,找规律,特别注意负数取mod. #include <iostream> #include &l ...
- The Cow Lineup_找规律
Description Farmer John's N cows (1 <= N <= 100,000) are lined up in a row.Each cow is labeled ...
- HDU 5753 Permutation Bo (推导 or 打表找规律)
Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
- 计蒜客 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 ...
- 暑假集训 #3div2 C Sequence 数字找规律
C. Sequence (64 Mb, 1 sec / test)Integer sequences are very interesting mathematical objects. Let us ...
- hdu4952 Number Transformation (找规律)
2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...
- CF456B Fedya and Maths 找规律
http://codeforces.com/contest/456/problem/B CF#260 div2 B Fedya and Maths Codeforces Round #260 B. F ...
随机推荐
- jquery封装多棵并列树
起因:当前的树都是在一棵树上,应产品需求,现在需要将一级菜单并列开,然后往下铺,这样只好自己写了. demo图: 我直接封在了jquery上,此外还加了获取勾选数据的一些简单API. 思路:先把一级菜 ...
- Topoi 测验1301, 问题C: 1959: 解题 解题报告
Topoi(一个经常会炸的网站) 本题提交链接 很久以前的题目了, 刚开了博客,来写一波题解 先看一波提交记录: 调了好几天QAQ 唉! 要是这些高手里有我估计直接 输出1 就AC了 算法 DFS + ...
- 给奇数的li标签添加蓝色,给偶数的li标签添加红色
今天遇到的面试题,哎,不看参考手册还是写的蛋疼啊!给奇数的li标签添加红色,给偶数的li标签添加蓝色 直接撸代码吧: <!DOCTYPE html> <html lang=" ...
- 上传图片时实时显示功能使用uploadPreview.js
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>添加商品分类</tit ...
- 生产阶段Webpack打包【基础打包】
webpack打包 1.在根目录创建一个 webpack.config.prod.js[它其实就是在开发阶段的基础上增加点东西] 增加了 output 去除了 devServer 2.在package ...
- win10的一些设置
win10进入安全模式: 左下角->设置->更新和安全->恢复->立即重启 (重启后进入的界面可以进行一些设置来进入安全模式) win10切换账户: 任务管理器->账户
- Python3基础(1)Python介绍、Python2 与Python3、变量、用户输入、if...else和for循环、while循环、break与continue
---------------个人学习笔记--------------- ----------------本文作者吴疆-------------- ------点击此处链接至博客园原文------ P ...
- <s:property>的用法
1,访问Action值栈中的普通属性: <s:property value="attrName"/> 2,访问Action值栈中的对象属性(要有get set方法): ...
- matlab 基本操作
导入excel 右键excel文件, import data, 选择column vector点击导入即可, 在右侧的workspace就可以看到添加的列变量了 在workspace中右键添加clas ...
- Unity Download Assistant Error: 'SendRequest Error' while downloading ini file from http://files.unity3d.com/bootstrapper/29055738eb78/unity-5.3.6f1-win.ini
Unity 官网的哥们如此说道 I open the exe on Compatibility Mode , it's solved. You can try. :) 翻译就是 我用兼容模式打开,就能 ...