## DMOPC '20 Contest 4 P1 - Missing Numbers

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

You are learning how to count in math class today! To demonstrate this invaluable ability, your teacher wrote the first positive integers on the chalkboard. However, when he went for a quick bathroom break, Jennifer the delinquent took the chance to erase of the numbers on the board! When your teacher returned, he summed up all the remaining numbers on the board and called it . Naturally, since your teacher is a genius, he did not mess up his calculations when summing up the numbers and is computationally correct. However, wasn't exactly the number he expected to get! As the teacher's pet an exemplary student, please help your teacher find the number of possible unordered pairs of numbers Jennifer erased. To ensure the integrity of your solution, there may be up to test cases.

#### Input Specification

The first line contains an integer , the number of test cases. The next lines describe the test cases.

The first and only line of each test case contains integers and , as specified in the problem statement.

#### Output Specification

For each test case output one integer on its own line, the number of possible unordered pairs of numbers Jennifer erased.

#### Sample Input

2
5 9
2 0

#### Sample Output

2
1

#### Explanation

For the first test case, your teacher initially wrote the numbers on the board. After Jennifer erased numbers, the remaining sum is . There are possible unordered pairs of numbers Jennifer could've erased, namely leaving , or leaving .

For the second test case, the only possibility is that Jennifer erased and since those are the only numbers on the board, so the answer is .

• commented on March 15, 2021, 11:18 a.m. edit 2

Could anyone who completed this question explain why I might be getting case #5 of batch 3 wrong? Is there something I'm not accounting for? (My submission: https://dmoj.ca/src/3489859)

Edit: Fixed

• commented on March 16, 2021, 7:29 a.m. edited

Could you please tell me how you fixed it? I'm stuck at branch 3 #5 too

Edit: Fixed too.

• commented on March 15, 2021, 12:20 a.m.

This comment is hidden due to too much negative feedback. Click here to view it.