PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000092. Noora và số lần so sánh tối thiểu (My Pretty Girl Noora)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Noora và số lần so sánh tối thiểu (My Pretty Girl Noora)
My Pretty Girl Noora
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
In a selection contest with participants, every round with participants chooses an integer dividing , forms groups of exactly people, compares every pair within each group ( comparisons per group), then advances one person from each group. Repeat until one participant remains. Let be the minimum total number of comparisons. Given , calculate modulo .
Input
One line contains three integers .
Output
Print the value of the expression modulo .
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
2 2 4
Output
19
Explanation
We have ; since three contestants must form one group; by forming two pairs (two comparisons) then comparing the two winners (one more). For , the result is .