CF2171H.Shiori Miyagi and Maximum Array Score

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

"Are you stupid, Sendai-san?"

— Shiori Miyagi

For the cost of 5000 yen, Miyagi can ask Sendai to do whatever she wants! Today, Miyagi demands that Sendai make her an array... specifically, Miyagi only wants a very particular type of array.

For arbitrary integers b≥2b\geq 2 and x≥1x\geq 1, define v(b,x)v(b, x) to be the maximal kk satisfying bk∣xb^k \mid x; that is, the maximal kk such that xx is a multiple of bkb^k. It can be shown that this is always a well-defined, nonnegative integer.

You are given integers nn and mm satisfying n≤mn\leq m. Find the maximum value of ∑i=2nv(i,ai)\sum_{i=2}^n v(i, a_i) across all arrays aa of length nn satisfying the following conditions:

  • aa is strictly increasing; that is, for all 1≤i≤n−11\leq i\leq n-1, ai<ai+1a_i \lt a_{i+1}, and
  • for all 1≤i≤n1\leq i\leq n, 1≤ai≤m1\leq a_i\leq m.

“你是不是傻,千田君?”

—— 宫城汐里

只需花费 5000 日元,宫城就能要求千田做任何她想让他做的事!今天,宫城要求千田为她构造一个数组……更准确地说,宫城只想要一种非常特殊的数组。

对任意整数 b≥2b\geq 2 和 x≥1x\geq 1,定义 v(b,x)v(b, x) 为满足 bk∣xb^k \mid x 的最大整数 kk;即,使得 xx 是 bkb^k 的倍数的最大 kk。可以证明,该值恒为定义良好且非负的整数。

给定满足 n≤mn\leq m 的整数 nn 和 mm。在所有满足以下条件的长度为 nn 的数组 aa 中,求 ∑i=2nv(i,ai)\sum_{i=2}^n v(i, a_i) 的最大可能值:

  • aa 是严格递增的;即,对所有 1≤i≤n−11\leq i\leq n-1,有 ai<ai+1a_i \lt a_{i+1};
  • 对所有 1≤i≤n1\leq i\leq n,有 1≤ai≤m1\leq a_i\leq m。

输入格式

The first line contains a single integer tt (1≤t≤1041 \leq t \leq 10^4) — the number of test cases.

The only line of each test case contains two integers nn and mm (2≤n≤m≤2⋅1052\leq n\leq m \leq 2\cdot 10^5).

It is guaranteed that the sum of mm over all test cases does not exceed 2⋅1052\cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \leq t \leq 10^4)—— 测试用例的数量。

每个测试用例仅有一行,包含两个整数 nn 和 mm(2≤n≤m≤2⋅1052\leq n\leq m \leq 2\cdot 10^5)。

保证所有测试用例的 mm 值之和不超过 2⋅1052\cdot 10^5。

输出格式

For each test case, output a single integer, the maximum value of ∑i=2nv(i,ai)\sum_{i=2}^n v(i, a_i) across all arrays aa of length nn satisfying the given conditions.

对于每个测试用例,输出一个整数,即在所有满足给定条件的长度为 nn 的数组 aa 中,∑i=2nv(i,ai)\sum_{i=2}^n v(i, a_i) 的最大值。

输入输出样例

  • 输入#1

    6
    4 20
    6 6
    6 216
    3 500
    2 8
    5 29

    输出#1

    7
    5
    19
    13
    3
    9

说明/提示

In the first example, one possible array is a=[6,8,9,16]a = [6, 8, 9, 16] which yields a value of 3+2+2=73 + 2 + 2 = 7.

It can be shown that this is the maximum value of ∑i=2nv(i,ai)\sum_{i=2}^n v(i, a_i) across all arrays aa of length nn satisfying the given conditions.

在第一个例子中,一个可能的数组是 a=[6,8,9,16]a = [6, 8, 9, 16],其对应的值为 3+2+2=73 + 2 + 2 = 7。

可以证明,对于所有满足给定条件的长度为 nn 的数组 aa,该值 ∑i=2nv(i,ai)\sum_{i=2}^n v(i, a_i) 达到最大值。

输入解题思路,AI测评打分。不知道怎么写?

首页