#GL0000388. Phân hoạch nghệ thuật (Artistic Partition)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Phân hoạch nghệ thuật (Artistic Partition)
Artistic Partition
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
For positive integers , let be the number of integer pairs such that
Given integers with , partition the integers into exactly non-empty consecutive segments covering all values. If the segments are , minimize
Equivalently, choose and use segments .
PHOJ convention: Each input file contains one pair and no leading test count .
Input
A line containing .
Output
The minimum possible sum of segment costs.
Subtasks
-
Subtask 1 (20 points): .
-
Subtask 2 (30 points): .
-
Subtask 3 (50 points): .
Examples
Example 1
Input
6 2
Output
8
Explanation
The two segments and have costs and respectively, for a minimum sum of . The five valid pairs in are .
Example 2
Input
4 4
Output
4
Explanation
Every segment must be a singleton and contributes exactly one pair.
Example 3
Input
10 3
Output
11
Explanation
One optimal partition is , with costs , respectively.