A16451 | Good Triples
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Given a non-negative integer number $n$ ( $n \ge 0$ ). Let's say a triple of non-negative integers $(a, b, c)$ is good if $a + b + c = n$ , and $digsum(a) + digsum(b) + digsum(c) = digsum(n)$ , where $digsum(x)$ is the sum of digits of number $x$ .
For example, if $n = 26$ , then the pair $(4, 12, 10)$ is good, because $4 + 12 + 10 = 26$ , and $(4) + (1 + 2) + (1 + 0) = (2 + 6)$ .
Your task is to find the number of good triples for the given number $n$ . The order of the numbers in a triple matters. For example, the triples $(4, 12, 10)$ and $(10, 12, 4)$ are two different triples.
For example, if $n = 26$ , then the pair $(4, 12, 10)$ is good, because $4 + 12 + 10 = 26$ , and $(4) + (1 + 2) + (1 + 0) = (2 + 6)$ .
Your task is to find the number of good triples for the given number $n$ . The order of the numbers in a triple matters. For example, the triples $(4, 12, 10)$ and $(10, 12, 4)$ are two different triples.
输入格式
The first line of input contains a single integer $t$ ( $1 \le t \le 10^4$ ) — the number of test cases. Descriptions of test cases follow.
The first and only line of the test case contains one integer $n$ ( $0 \le n \le 10^7$ ).
The first and only line of the test case contains one integer $n$ ( $0 \le n \le 10^7$ ).
输出格式
For each test case output one integer, the number of good triples for the given integer $n$ . Order of integers in a triple matters.
输入输出样例
输入 #1
12 11 0 1 2 3 4 5 3141 999 2718 9999999 10000000
输出 #1
9 1 3 6 10 15 21 1350 166375 29160 1522435234375 3
In the first example, the good triples are $(0, 0, 11)$ , $(0, 1, 10)$ , $(0, 10, 1)$ , $(0, 11, 0)$ , $(1, 0, 10)$ , $(1, 10, 0)$ , $(10, 0, 1)$ , $(10, 1, 0)$ , $(11, 0, 0)$ .
In the second example, there is only one good triple $(0, 0, 0)$ .
In the second example, there is only one good triple $(0, 0, 0)$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted