PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000062. Biểu diễn số K-tốt (K-good)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Biểu diễn số K-tốt (K-good)
K-good
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A positive integer n is k-good if it is the sum of exactly k positive integers whose remainders modulo k are pairwise distinct. Find any integer k>=2 for which n is k-good; print -1 if no such k exists. Different valid values of k are all accepted.
Input
An integer n.
Output
Any valid k>=2 or -1 if no valid value exists.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
6
Output
3
Explanation
The representation 6=1+2+3 has three distinct remainders modulo 3.