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 个传送器,并且对于每 ...
随机推荐
- 油田(DFS)
//DFS:油田问题 #include <iostream> using namespace std; ][]; int n,m; //一个网格的8个方向 ][] = {{-,-},{-, ...
- mysql错误:Column ‘id’ in field list is ambiguous的解决方法
[Err] 1052 - Column 'modify_time' in where clause is ambiguous 出错的语句: SELECT AVG(T.se)%60FROM( SELEC ...
- Kotlin中功能操作与集合(KAD 11)
作者:Antonio Leiva 时间:Feb 2, 2017 原文链接:https://antonioleiva.com/functional-operations-collections-kotl ...
- 使用jquery validate结合zui作表单验证
1.引入jquery validate和zui <!-- jQuery (ZUI中的Javascript组件依赖于jQuery) --> <script src="${_b ...
- 关于用python作为第三方程序,来调用shell命令的问题,以及返回值格式解析
1.用python语言作为第三方,调用shell 在python2.x中,可以通过包commands来进行调用shell命令.如下: cmd就是你要调用的shell命令,把环境配置好,输入正确的命令格 ...
- 孤荷凌寒自学python第三十二天python的代码块中的异常的捕获
孤荷凌寒自学python第三十二天python的代码块中的异常的捕获 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 今天简单了解了Python的错误陷阱,了解到其与过去学过的其它语言非常类似 ...
- 孤荷凌寒自学python第十一天初识Python的字典类
孤荷凌寒自学python第十一天初识Python的字典类 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) Python的字典其实是一张二维对照表 下面举例说明: 键名Key 姓名 性别 身高 ...
- 一步步精通NodeJs的简单实例
一步一步完成nodejs+express+mysql的简单实例开发 1.使用express创建简单web服务器 项目文件下安装express,这个不多说,很简单,直接在项目目录下运行 npm inst ...
- html span和div的区别
div与span区别及用法 div与span区别及用法 DIV与SPAN区别及div与san用法篇 接下来了解在div+css开发的时候在html网页制作,特别是标签运用中div和span的区别及用法 ...
- HDU 1171 Big Event in HDU 母函数
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory ...