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 integers 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 satisfy 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.

• commented on Nov. 17, 2020, 8:38 p.m.

What am I doing wrong for the last test cases? Keep getting WA.

• commented on Nov. 17, 2020, 9:19 p.m.

You are outputting your answers mod instead of by mod . Your code, counter%(10000000000+7), has one extra zero.

If you want to avoid similar issues in the future, try defining a global variable for your "mod" constant for consistency.

Such as with int mod = 1e9+7; in C++. So, use counter%mod in that case.

• commented on Nov. 18, 2020, 7:36 p.m.

Thanks! I completely missed that one.

• commented on Nov. 11, 2020, 7:12 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Nov. 12, 2020, 4:55 p.m. edited

I thought you said you were good enough to qualify for IOI 2022

• commented on Nov. 12, 2020, 5:29 p.m. edited

again, hes just smurfing and pretending to be bad. smh. He's guaranteed ioi 2022 watch.

• commented on June 30, 2020, 10:41 p.m. edited

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on July 2, 2020, 3:34 p.m.

So solutions like yours can't pass. Find a more efficient way to solve the problem.