No.2709 1975 Powers
Problem Statement
There is a sequence $A = (A_1,A_2,\dots,A_N)$ consisting of $N$ integers.
Among the ways to choose $4$ distinct integers $a,b,c,d$ from $A$, find the number of ways that satisfy the following conditions.
- $10^a+9^b+7^c+5^d$ leaves a remainder of $Q$ when divided by $P$
- $a < b < c < d$
Input
$N \ P \ Q$ $A_1 \ A_2 \ \dots \ A_N$
- $4 \leq N \leq 200$
- $2 \leq Q < P \leq 10^5$
- $1 \leq A_i \leq 2 \times 10^6$
- $A_i \neq A_j \ (i \neq j)$
- All inputs are integers
Output
Find and output the number of ways to choose 4 integers that satisfy the conditions.
Sample
Sample 1
Input
5 7 5 7 3 9 6 10
Output
1
Only the following tuple $a,b,c,d$ satisfies the condition of leaving a remainder of $5$ when divided by $7$.
$(a,b,c,d)=(6,7,9,10):10^6+9^7+7^9+5^{10} = 55902201$
Sample 2
Input
5 8 3 1 2 3 5 8
Output
3
The following $3$ tuples $a,b,c,d$ satisfy the condition of leaving a remainder of $3$ when divided by $8$.
$(a,b,c,d)=(1,2,3,8):10^1+9^2+7^3+5^8 = 391059$
$(a,b,c,d)=(1,2,5,8):10^1+9^2+7^5+5^8 = 407523$
$(a,b,c,d)=(1,3,4,8):10^1+9^3+7^4+5^8 = 408171$
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
sepa38