HDU 5916: Harmonic Value Description
题目描述
$$\sum_{i=1}^{n-1} gcd(p_i.p_{i+1})$$
Mr. Frog is wondering about the permutation whose harmonic value is the strictly k-th smallest among all the permutations of [n].
输入
For each test case, there is only one line describing the given integers n and k ($1\leq 2k \leq n \leq10000$).
输出
样例输入
样例输出
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#define range(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
#define rerange(i,a,b) for(int i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
using namespace std;
int t;
void init() {
cin>>t;
}
void solve(){
int cas=;
while(t--){
int n,k;
cin>>n>>k;
cout<<"Case #"<<++cas<<": "<<(k<<)<<" "<<k;
range(i,k+,n){
if(i==(k<<))continue;
cout<<" "<<i;
}
range(i,,k-)cout<<" "<<i;
cout<<endl;
}
}
int main() {
init();
solve();
return ;
}
HDU 5916: Harmonic Value Description的更多相关文章
- HDU 5916 Harmonic Value Description 【构造】(2016中国大学生程序设计竞赛(长春))
Harmonic Value Description Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Ja ...
- HDU 5916 Harmonic Value Description (构造)
题意:给你 n 和 m,求一个1-n的排列,使得∑gcd(Ai,Ai+1) 恰为第 m 小. 析:可以想到最小的就是相邻都互质,然后依次,第 m 小就可以有一个是gcd为 k,然后其他的为1喽. 那 ...
- Harmonic Value Description HDU - 5916
The harmonic value of the permutation p1,p2,⋯pn is ∑i=1n−1gcd(pi.pi+1) Mr. Frog is wondering about t ...
- Harmonic Value Description(构造题)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission ...
- 2016 CCPC长春重现赛
1.2016中国大学生程序设计竞赛(长春)-重现赛 2.总结:会做的太少,应变能力也不行,或者说猜题目的能力不行 02 水 04 HDU 5914 Triangle 1.题意:1~n,n个数,问 ...
- 2016CCPC长春 - B/D/F/H/I/J/K - (待补)
目录: B - Fraction D - Triangle F - Harmonic Value Description H - Sequence I I - Sequence II B题:HDU 5 ...
- 数位DP入门之hdu 3652 B-number
hdu 3652 B-number Problem Description A wqb-number, or B-number for short, is a non-negative integer ...
- cdq分治(hdu 5618 Jam's problem again[陌上花开]、CQOI 2011 动态逆序对、hdu 4742 Pinball Game、hdu 4456 Crowd、[HEOI2016/TJOI2016]序列、[NOI2007]货币兑换 )
hdu 5618 Jam's problem again #include <bits/stdc++.h> #define MAXN 100010 using namespace std; ...
- HDU 6787 Chess 2020百度之星 初赛三 T5 题解 dp
传送门:HDU 6787 Chess Problem Description 你现在有一个棋盘,上面有 n 个格子,格子从左往右,1,-,n 进行标号.你可以在棋盘上放置恰好 m 个传送器,并且对于每 ...
随机推荐
- javascript将分,秒,毫秒转换为xx天xx小时xx秒(任何语言通用,最通俗易懂)
// 传入参数为总分钟数,如果为秒数,毫秒数,需要对 // 此处得到总秒数 注释部分的代码调整下. function toDateDMS(minutes){ // 将分钟转换为 天,时,分,秒 if( ...
- Xcode坑之一Invalid argument
Xcode坑之一Invalid argument 正在搞代码,运行程序时突然发现程序不能再次运行了,一运行就提示Invalid argument 然后FQ各种查啊,试了好多方法都不行,重启,重置,我用 ...
- appium-手势密码实现-automationName 是Appium的情况
1. 红色区域的范围为:[66,575][1014,1523], 由于这块是一个整块,所以无法使用每个点的数据:因此只能使用LockPatternView对象拿到左上角的坐标值 2. 原理, 将九宫 ...
- Oracle 学习----游标(使用带参光标cursor)
--表参照无参光标页信息 --注意:红色就是参数 declare cursor tt(pkeycode temp.keycode%type) is select name,sal from temp ...
- IntelliJ IDEA 注释模版 输入/**后 不显示配置好的模板
简单一句话就是 当你在live templetes里配置好以后,记住abbreviation:输入框里的字母 比如我的是cc ,我要想写注释怎么办? 在方法上输入 /*cc 然后按tab键就出来了
- 聊聊、Spring WebApplicationInitializer
说到 WebApplicationInitializer,这个接口是为了实现代码配置 Web 功能.只要实现了这个接口,那么就可以实现 Filter,Servlet,Listener 等配置,跟在 x ...
- webpack 基础
1.安装: npm install --save-dev webpack npm install --save-dev webpack@<version> 如果是webpa ...
- HttpClient实现POST参数提交
HttpClient client = new HttpClient(); //使用FormUrlEncodedContent做HttpContent var content = new FormUr ...
- 【转】Itween 贝塞尔曲线(一)
原地址:点击打开链接 1.回调函数 回调函数,即当动画完成时那瞬间需要执行一次的一个函数,it中默认有一个onComplete函数,当动画完成时会自动执行,且你可以提供需要传递的一些参数.见如下代码: ...
- 第十一篇:MySQL基础
本篇内容 MySQL概述 MySQL安装 MySQL库增.删.改.查 MySQL表增.删.改.查 MySQL表记录增.删.改.查 一. MySQL概述 MySQL是一个关系型数据库管理系统,由瑞典 M ...