HDU5916
Harmonic Value Description
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 287 Accepted Submission(s): 184
Special Judge
Problem Description
∑i=1n−1gcd(pi.pi+1)
Mr. Frog is wondering about the permutation whose harmonic value is the strictly k-th smallest among all the permutations of [n].
Input
For each test case, there is only one line describing the given integers n and k (1≤2k≤n≤10000).
Output
Sample Input
Sample Output
Source
//2016.10.08
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int main()
{
int T, n, k, kase = ;
scanf("%d", &T);
while(T--)
{
int tmp = -;
scanf("%d%d", &n, &k);
printf("Case #%d:", ++kase);
if(k == ){
for(int i = ; i <= n; i++)
printf(" %d", i);
}else{
if(k&){
printf(" %d %d", *k, k);
for(int i = ; i <= n; i++)
{
if(i == *k)continue;
if(i == k)printf("");
else printf(" %d", i);
}
}else{
printf(" %d %d", *k, k);
for(int i = ; i <= n; i++)
{
if(i == k || i == *k)continue;
else printf(" %d", i);
}
}
}
printf("\n");
} return ;
}
HDU5916的更多相关文章
随机推荐
- Vmware克隆虚拟机后网卡eth0变eth1解决
在克隆虚拟机的过程中,发现新克隆的机器的网卡由eth0变成了eth1,然而并没有eth1的配置文件. 1.#ip a 查看当前ip地址,发现是eth1网卡 2.#ll /etc/sysconfig/n ...
- iframe与父页面的js通信
1.父页面调用iframe中的函数: document.getElementById('myframe').contentWidow.fun1(); 2.在iframe中调用父页面中的函数: wind ...
- Nginx日志配置及日志切割
日志配置 日志对于统计排错来说非常有利的.本文总结了nginx日志相关的配置如access_log.log_format.open_log_file_cache.log_not_found.log_s ...
- 静态方法List
public class Country { public static List<Country> CountryList = new List<Country> { new ...
- linux 驱动入门3
不吃苦中苦,难为人上人.努力,给老婆孩子提供个良好的生活居住环境. http://www.cnblogs.com/nan-jing/articles/5806399.html 上文提到.可以自动创建了 ...
- highcharts柱状图和饼图的数据填充
1.其实数据填充很简单,它们就是json的格式,然后后台按照这种格式去套数据发给前端:前端再做一下连接处理等就行了. $('#program_statistics_bar').highcharts({ ...
- LPC1788的ADC和DAC使用
#ifndef __ADC1_H_ #define __ADC1_H_ #include "common.h" #include "delay.h" void ...
- S3C2440 TFTLCD驱动详解
S3C2440自带有LCD控制器,该控制器主要有以下接口 仅仅说TFT显示器,TFT显示器的时序如下 TFT显示器的驱动是以行列的形式逐点扫描过来的,驱动时钟有三种,一种是行时钟,一种是列时钟,还有一 ...
- C++中string类的使用方法
如果所比较的两个string 相等,则返回0: 操作string 大于参数string,返回 正数:操作string 小于参数string,返回负数. (1) 比较操作string 与 _Str 或C ...
- Myeclipseforspring 10破解
破解包和说明下载网址:http://ishare.iask.sina.com.cn/f/33848276.html?all=y