#abc335b. B - Tetrahedral Number
B - Tetrahedral Number
Score : points
问题描述
给定一个整数 。
按照升序字典序打印满足条件 的所有非负整数三元组 。
非负整数三元组的字典序是什么?
如果以下任意条件成立,则称非负整数三元组 在字典序上 小于 三元组 :
- ;
- 且 ;
- 且 且 .
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given an integer .
Print all triples of non-negative integers such that in ascending lexicographical order.
What is lexicographical order for non-negative integer triples?
A triple of non-negative integers is said to be lexicographically smaller than if and only if one of the following holds:
- ;
- and ;
- and and .
Constraints
- is an integer.
Input
The input is given from Standard Input in the following format:
Output
Print all triples of non-negative integers such that in ascending lexicographical order, with separated by spaces, one triple per line.
Sample Input 1
3
Sample Output 1
0 0 0
0 0 1
0 0 2
0 0 3
0 1 0
0 1 1
0 1 2
0 2 0
0 2 1
0 3 0
1 0 0
1 0 1
1 0 2
1 1 0
1 1 1
1 2 0
2 0 0
2 0 1
2 1 0
3 0 0
Sample Input 2
4
Sample Output 2
0 0 0
0 0 1
0 0 2
0 0 3
0 0 4
0 1 0
0 1 1
0 1 2
0 1 3
0 2 0
0 2 1
0 2 2
0 3 0
0 3 1
0 4 0
1 0 0
1 0 1
1 0 2
1 0 3
1 1 0
1 1 1
1 1 2
1 2 0
1 2 1
1 3 0
2 0 0
2 0 1
2 0 2
2 1 0
2 1 1
2 2 0
3 0 0
3 0 1
3 1 0
4 0 0
update @ 2024/3/10 01:23:03