## CCCHK '15 S1 - Finding number of pairs

View as PDF

Points: 7 (partial)
Time limit: 0.1s
Java 0.3s
Python 2 0.3s
Python 3 0.3s
Memory limit: 256M

Problem type

Given a sequence of integers and a nonnegative integer , count the number of pairs that satisfy the following two conditions: , and .

#### Input specification:

• The first line contains integer and , separated by a space.
• The second line contains integers, which denotes
• In of the test cases, .

#### Output specification:

• The output contains an integer, which denotes the number of pairs that satisfies the two conditions.
• If the output is smaller than , please keep it as is. Otherwise, output the number mod .

#### Sample Input 1

5 6
1 2 3 4 5

#### Sample Output 1

6

#### Sample Input 2

5 12
3 6 8 2 8

#### Sample Output 2

7

Explanation: In Sample 1, among the pairs, , , , , , satisfy the conditions. In Sample 2, , , , , , , satisfy the conditions.