#P15678. [ICPC 2024 Jakarta R] GCDDCG
[ICPC 2024 Jakarta R] GCDDCG
题目描述
You are playing the Greatest Common Divisor Deck-Building Card Game (GCDDCG). There are cards (numbered from to ). Card has the value of , which is an integer between and (inclusive).
The game consists of rounds (numbered from to ). Within each round, you need to build two non-empty decks, deck and deck . A card cannot be inside both decks, and it is allowed to not use all cards. In round , the greatest common divisor (GCD) of the card values in each deck must equal .
Your creativity point during round is the product of and the number of ways to build two valid decks. Two ways are considered different if one of the decks contains different cards.
Find the sum of creativity points across all rounds. Since the sum can be very large, calculate the sum modulo .
输入格式
The first line consists of an integer ( .
The second line consists of integers ( ).
输出格式
Output a single integer representing the sum of creativity points across all rounds modulo .
3
3 3 3
36
4
2 2 4 4
44
9
4 2 6 9 7 7 7 3 3
10858
提示
Explanation for the sample input/output #1
The creativity point during each of rounds and is .
During round , there are ways to build both decks. Denote and as the set of card numbers within deck and deck , respectively. The ways to build both decks are:
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ; and
- .
Explanation for the sample input/output #2
For rounds , , and , there are , , , and ways to build both decks, respectively.