#K10491. Organize Books into Sections
Organize Books into Sections
Organize Books into Sections
The problem asks you to determine whether it is possible to organize n books, numbered from 1 to n, into k sections such that the sum of the book IDs in each section is equal. Note that the total sum of book IDs is given by the formula:
\( S = \frac{n(n+1)}{2} \)
You need to check if \( S \) is divisible by k. If it is, print YES
; otherwise, print NO
.
inputFormat
The input contains a single line with two space-separated integers n and k, where n represents the number of books and k represents the number of sections.
outputFormat
Output a single line containing YES
if it is possible to partition the books into k sections with equal sum of IDs, otherwise output NO
.
6 3
YES