CF1603D.Artistic Partition
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For two positive integers l and r (l≤r) let c(l,r) denote the number of integer pairs (i,j) such that l≤i≤j≤r and gcd(i,j)≥l. Here, gcd(i,j) is the greatest common divisor (GCD) of integers i and j.
YouKn0wWho has two integers n and k where 1≤k≤n. Let f(n,k) denote the minimum of i=1∑kc(xi+1,xi+1) over all integer sequences 0=x1<x2<…<xk<xk+1=n.
Help YouKn0wWho find f(n,k).
对于两个正整数 l 和 r(满足 l≤r),定义 c(l,r) 为满足 l≤i≤j≤r 且 gcd(i,j)≥l 的整数对 (i,j) 的个数。其中,gcd(i,j) 表示整数 i 与 j 的最大公约数(GCD)。
YouKn0wWho 有两个整数 n 和 k,满足 1≤k≤n。定义 f(n,k) 为对所有满足 0=x1<x2<…<xk<xk+1=n 的整数序列,表达式 i=1∑kc(xi+1,xi+1) 的最小值。
请帮助 YouKn0wWho 求出 f(n,k)。
输入格式
The first line contains a single integer t (1≤t≤3⋅105) — the number of test cases.
The first and only line of each test case contains two integers n and k (1≤k≤n≤105).
第一行包含一个整数 t(1≤t≤3⋅105)—— 测试用例的数量。
每个测试用例仅有一行,包含两个整数 n 和 k(1≤k≤n≤105)。
输出格式
For each test case, print a single integer — f(n,k).
对于每个测试用例,输出一个整数——f(n,k)。
输入输出样例
输入#1
4 6 2 4 4 3 1 10 3
输出#1
8 4 6 11
说明/提示
In the first test case, YouKn0wWho can select the sequence [0,2,6]. So f(6,2)=c(1,2)+c(3,6)=3+5=8 which is the minimum possible.
在第一个测试用例中,YouKn0wWho 可以选择序列 [0,2,6]。因此 f(6,2)=c(1,2)+c(3,6)=3+5=8,这是可能的最小值。
输入解题思路,AI测评打分。不知道怎么写?