atcoder#ARC160C. [ARC160C] Power Up
[ARC160C] Power Up
Score : points
Problem Statement
You are given a multiset of positive integers with elements: .
You may repeat the following operation any number of times (possibly zero).
- Choose a positive integer that occurs at least twice in . Delete two occurrences of from , and add one occurrence of to .
Find the number, modulo , of multisets that can be in the end.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
4
1 1 2 4
3
can be one of the three multisets $\lbrace 1,1,2,4 \rbrace,\lbrace 2,2,4 \rbrace,\lbrace 3,4 \rbrace$ in the end.
You can make as follows.
- Choose . Delete two s from and add one to , making .
- Choose . Delete two s from and add one to , making .
5
1 2 3 4 5
1
13
3 1 4 1 5 9 2 6 5 3 5 8 9
66