#K78457. Pet Distribution
Pet Distribution
Pet Distribution
You are given a number of test cases. For each test case, you are provided with a single integer n representing the total number of people in a group. For each test case, your task is to generate and output all pairs of non-negative integers \( (x, y) \) that satisfy the inequality \( x + y \le n \).
Each pair \( (x, y) \) represents a possible distribution of people owning cats and dogs, where \(x\) might denote the number of people owning cats and \(y\) the number of people owning dogs. The pairs should be printed one per line, with a single space separating the two numbers. If there are multiple test cases, separate the output for each test case with an empty line.
Note: Input will be taken from standard input and output should be printed to standard output.
inputFormat
The first line of input contains a single integer t
denoting the number of test cases. The following t
lines each contain one integer n
which represents the total number for that test case.
Example:
3 2 3 1
This example indicates that there are 3 test cases with n = 2
for the first test case, n = 3
for the second test case, and n = 1
for the third test case.
outputFormat
For each test case, output all pairs \( (x, y) \) (one per line) that satisfy \( x + y \le n \), where n
is the integer provided in that test case. Separate the output for consecutive test cases with an empty line.
For instance, for an input test case with n = 2
, the output should be:
0 0 0 1 0 2 1 0 1 1 2 0## sample
1
2
0 0
0 1
0 2
1 0
1 1
2 0
</p>