CF1603D.Artistic Partition

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

For two positive integers ll and rr ( lrl \le r ) let c(l,r)c(l, r) denote the number of integer pairs (i,j)(i, j) such that lijrl \le i \le j \le r and gcd(i,j)l\operatorname{gcd}(i, j) \ge l . Here, gcd(i,j)\operatorname{gcd}(i, j) is the greatest common divisor (GCD) of integers ii and jj .

YouKn0wWho has two integers nn and kk where 1kn1 \le k \le n . Let f(n,k)f(n, k) denote the minimum of i=1kc(xi+1,xi+1)\sum\limits_{i=1}^{k}{c(x_i+1,x_{i+1})} over all integer sequences 0=x1<x2<<xk<xk+1=n0=x_1 \lt x_2 \lt \ldots \lt x_{k} \lt x_{k+1}=n .

Help YouKn0wWho find f(n,k)f(n, k) .

输入格式

The first line contains a single integer tt ( 1t31051 \le t \le 3 \cdot 10^5 ) — the number of test cases.

The first and only line of each test case contains two integers nn and kk ( 1kn1051 \le k \le n \le 10^5 ).

输出格式

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][0, 2, 6] . So f(6,2)=c(1,2)+c(3,6)=3+5=8f(6, 2) = c(1, 2) + c(3, 6) = 3 + 5 = 8 which is the minimum possible.

首页