Count Pairs
Easy Accuracy: 12.77% Submissions: 499 Points: 2

Given two non-negative integers A, B. Find number of pairs of integers (a,b) such that:
a+b=A and a3+b3=B

Input:
The first line of the test case contains an integer T denoting number of test cases. Each line of the test case contains two space separated integer A and B.

Output:
For each of the test case print the answer in separate line.

Constraints:
1 <= T <= 2.3*103

0 <= A,B <= 106

Examples:
Input:
1
3 9

Output:
2

Explanation:
Only (1,2) and (2,1) are such pairs.

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.