luogu#P4963. 美樱的颜料

美樱的颜料

Background

After Chunhui went to the United States to study abroad, Miying often felt lonely. To ease her loneliness, she always has special requirements for paints when she draws.

Problem Description

Miying has nn different kinds of paints, numbered from 11 to nn. Each kind of paint can be used at most once. When she starts a painting, she may choose any one paint to use.

After that, each time Miying chooses a paint ii to use such that, after using paint ii, the gcdgcd (greatest common divisor) of the indices of all paints used so far is as large as possible, that is:

Let the set of indices of paints already used be AA. If $\ \exists\ i,\ j\notin A,\ i,\ j\in [1,\ n],\ gcd(A,\ i)>gcd(A,\ j)$, then paint jj cannot be chosen.

If there are multiple paints that satisfy the condition, Miying may choose any one of them. After each paint is used, Miying gains a happiness value equal to the gcdgcd of the indices of all paints used so far.

Now Miying wants to draw a painting using mm kinds of paints. What is the maximum possible sum of happiness values she can obtain?

Input Format

A single line with two positive integers n, mn,\ m, representing the number of kinds of paints and the number of paints Miying will use.

Output Format

Output one positive integer, the maximum happiness value Miying can obtain.

7 4
11
15 3
25

Hint

1mn1071\le m\le n\le 10^7.

Constraints

Sample Explanation

Sample 1: 6 3 5 2 is an optimal solution. The happiness values obtained each time are 6 3 1 1.

Sample 2: 15 10 5 is an optimal solution. The happiness values obtained each time are 15 5 5.

Translated by ChatGPT 5