Lulu and the Star Guardians
Time limit1sMemory limit1024 MB
Split guardians numbered 1 to N into teams of K so that no team's power sum is divisible by K, or report NO if that is impossible.
- Level
Medium6 of 10
- Topics
- Math, Greedy, Implementation
- Solved
- No attempts yet
Problem
Lulu is in charge of guarding the stars of the universe, and she has selected new star guardians to share her work. The combat power of the -th new guardian is .
Lulu wants to form teams, each with exactly new guardians, so that every new guardian is in a team. Each team is assigned to one star. is divisible by . When assigning teams to stars, follow this rule.
If the sum of the combat powers of the guardians assigned to the same star is divisible by , the star starts to collapse!
Help Lulu, who is weak at math, by finding how to assign the guardians so that no star collapses.
Input
The first line contains two integers and , separated by a space. is divisible by .
Output
On the first line, print YES if every guardian can be assigned so that no star collapses. Otherwise, print NO.
If such an assignment exists, print one valid assignment on the next lines. Each line contains the numbers of the guardians assigned to the same star, separated by spaces.