F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Harmonic Value Description

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 3089    Accepted Submission(s): 1585
Special Judge


Problem Description
The harmonic value of the permutation $p_1,p_2,\cdots p_n$ is
$$\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].
 

Input
The first line contains only one integer T ($1\leq T\leq 100$), which indicates the number of test cases.

For each test case, there is only one line describing the given integers n and k ($1\leq 2k \leq n \leq10000$).
 

Output
For each test case, output one line “Case #x: $p_1\ p_2\ \cdots \ p_n$”, where x is the case number (starting from 1) and $p_1\ p_2\ \cdots \ p_n$ is the answer.
 

Sample Input
2 4 1 4 2
 

Sample Output
Case #1: 4 1 3 2 Case #2: 2 4 1 3
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 13:03:53, Gzip enabled