Submit solution
Points:
1
Time limit:
1.0s
Memory limit:
256M
Input:
stdin
Output:
stdout
Author:
Problem type
Allowed languages
C++, Pascal, pypy3, Python
Given two integers n and x, your task is to count the number of ordered triplets (a, b, c) of positive integers such that the following conditions are satisfied:
- ab + ac + bc \leq n
- a + b + c \leq x
Notes: (a, b, c) is an triplet, meaning (1,1,2) and (1,2,1) are considered different. a, b, c > 0 (each element of the triplet must be strictly greater than zero).
Input:
- The first line contains an integer t ( 1 \leq t \leq 10^4 ) --- the number of test cases.
- Each test case consists of two integers n and x ( 1 \leq n, x \leq 10^6 ).
- The sum of all n values across test cases does not exceed 10^6 , and the sum of all x values across test cases does not exceed 10^6
Output:
- For each test case, print a single integer --- the number of valid triplets (a, b, c) .
Example:
Sample Input 1:
4
7 4
10 5
7 1000
900000 400000
Sample Output 1:
4
10
7
1768016938
Notes:
The triplets for the first test case are:
(1,1,1), (1,1,2), (1,2,1), (2,1,1).
The triplets for the second test case are:
(1,1,1), (1,1,2), (1,1,3), (1,2,1), (1,2,2), (1,3,1),
(2,1,1), (2,1,2), (2,2,1), (3,1,1).
Comments