THICC '17 P2 - Molly and Product
View as PDF
Submit solution
Points:
7 (partial)
Time limit:
1.0s
Memory limit:
16M
Python
128M
Author:
Problem type
Molly has a math addiction. For her birthday, she receives a sequence of length defined by
. Given the value of
, help Molly find the sum of all pairwise products, mod
.
Input Specification
The first and only line of input will contain ,
,
, and
, each space-separated.
Output Specification
The output should contain a single integer, the sum of all pairwise products, mod .
Constraints
For all subtasks:
Subtask 1 [40%]
Subtask 2 [40%]
Subtask 3 [20%]
Sample Input
3 6 3 100
Sample Output
2808
Explanation for Sample Output
The three numbers are ,
, and
. Their pairwise products are
,
,
,
,
and
and their sum is
.
Comments