PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000012. Tích hiệu theo mô-đun (Kuroni and Impossible Calculation)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tích hiệu theo mô-đun (Kuroni and Impossible Calculation)
Kuroni and Impossible Calculation
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given nonnegative integers and positive modulus , compute the product of over all pairs , modulo .
Input
First line: . Second line: values .
Output
Print the product modulo .
Subtasks
- Subtask 1 (20 points): ; ;
- Subtask 2 (30 points): ; ;
- Subtask 3 (50 points): ; ;
Examples
Input
2 10
8 5
Output
3
Explanation
There is only one pair, whose absolute difference is , so the result modulo is .