PivotOJ

I Would Walk 500 Miles

시간 제한: 2000ms메모리 제한: 512MB출처: USACO 2019 US Open Contest, GoldBOJ 17193

문제

Farmer John wants to divide his NN cows (N7500)(N \leq 7500), conveniently numbered 1N1 \ldots N, into KK non-empty groups (2KN2 \leq K \leq N) such that no two cows from two different groups can interact with each other without walking some number of miles. Cow xx and Cow yy (where 1x<yN1 \leq x < y \leq N) are willing to walk (2019201913x+2019201949y) mod 2019201997(2019201913x + 2019201949y)\text{ mod } 2019201997 miles to see each other.

Given a division of the NN cows into KK non-empty groups, let MM be the minimum of the number of miles any two cows in two different groups are willing to walk to see each other. To test the cows' devotion to each other, Farmer John wants to optimally divide the NN cows into KK groups such that MM is as large as possible.

입력

The input is just one line, containing NN and KK, separated by a space.

출력

Print out MM in an optimal solution.

힌트

In this example, Cow 1 and Cow 2 are willing to walk 2019201817 miles to see each other. Cow 2 and Cow 3 are willing to walk 2019201685 miles. And Cow 1 and Cow 3 are willing to walk 2019201769 miles. Thus, by grouping the cows such that 1 is by herself and 2 and 3 are grouped together, M=min(2019201817,2019201769)=2019201769M = \min(2019201817,2019201769) = 2019201769 (which is the best we can do here).

예제

예제 1

입력
3 2
출력
2019201769
코드를 제출하려면 로그인하세요.