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 ...
随机推荐
- 清北刷题冲刺 10-31 a.m
集合 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; ], ...
- 消耗战——dp+虚树
题目 [题目描述] 在一场战争中,战场由 $n$ 个岛屿和 $n-1$ 个桥梁组成,保证每两个岛屿间有且仅有一条路径可达.现在,我军已经侦查到敌军的总部在编号为 $1$ 的岛屿,而且他们已经没有足够多 ...
- Objective-C的Runtime System
[0] Outline -- [1] 版本和平台 -- [2] 与Runtime System交互 -- [3] 方法的动态决议 -- [4] 消息转发 -- [5] 类型编码 -- [6 ...
- Nacos深入浅出(十)
基本上到第9篇,整个请求的一套就结束了,感觉这里跳跳绕绕很多东西,下面我们来做个总结:从Nacos配置平台修改,到Client请求更新,事件触发去取值返回给客户端,整个过程感觉只分析到了4.5层的深度 ...
- iOS 限制TextField输入长度
1 #import "MyInfoEditTableViewCell.h" @interface MyInfoEditTableViewCell()<UITextFieldD ...
- webpack前端自动化构建工具
博主不易,不求赞赏,希望把自己遇到的难点写出来,以及希望自己能有能力写出一篇不错的博文. 前端构建工具本人 bootstrap+jquery用gulp vue+element 用webpack 本人最 ...
- SPGroup 和SPUser的常用操作
http://www.cnblogs.com/gzh4455/archive/2012/03/26/2417854.html private bool RemoveUserFromGroup(stri ...
- Linux如何用查看域名解析
方法/步骤 查看本地dns配置.确保能上网,dns配置正确.可以查看网卡配置文件和dns配置文件,网卡里配置优先. ping命令.第一行会返回域名及解析的ip. host命令.会返回域 ...
- 解决tomcat闪退问题
https://blog.csdn.net/zh2nd/article/details/79068680 转载此博客链接内容,非常感谢博主 本文参考CSDN博主 哈克沃德.的<Tomcat8启动 ...
- python3.6下安装wingIDE破解方法
1.wingIDE的下载: 在电脑配置好的python环境情况下,去官网下载wingIDE6,按照一般方式安装好.安装好它会自动提示你是否激活,你点击激活.然后到下一步. 2.脚本的制作: impor ...