A14534 | Carrying Conundrum
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice has just learned addition. However, she hasn't learned the concept of "carrying" fully — instead of carrying to the next column, she carries to the column two columns to the left.
For example, the regular way to evaluate the sum $2039 + 2976$ would be as shown:
However, Alice evaluates it as shown:
In particular, this is what she does:
- add $9$ and $6$ to make $15$ , and carry the $1$ to the column two columns to the left, i. e. to the column " $0$ $9$ ";
- add $3$ and $7$ to make $10$ and carry the $1$ to the column two columns to the left, i. e. to the column " $2$ $2$ ";
- add $1$ , $0$ , and $9$ to make $10$ and carry the $1$ to the column two columns to the left, i. e. to the column above the plus sign;
- add $1$ , $2$ and $2$ to make $5$ ;
- add $1$ to make $1$ .
Thus, she ends up with the incorrect result of $15005$ .Alice comes up to Bob and says that she has added two numbers to get a result of $n$ . However, Bob knows that Alice adds in her own way. Help Bob find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of $n$ . Note that pairs $(a, b)$ and $(b, a)$ are considered different if $a \ne b$ .
For example, the regular way to evaluate the sum $2039 + 2976$ would be as shown:
However, Alice evaluates it as shown:
In particular, this is what she does:
- add $9$ and $6$ to make $15$ , and carry the $1$ to the column two columns to the left, i. e. to the column " $0$ $9$ ";
- add $3$ and $7$ to make $10$ and carry the $1$ to the column two columns to the left, i. e. to the column " $2$ $2$ ";
- add $1$ , $0$ , and $9$ to make $10$ and carry the $1$ to the column two columns to the left, i. e. to the column above the plus sign;
- add $1$ , $2$ and $2$ to make $5$ ;
- add $1$ to make $1$ .
Thus, she ends up with the incorrect result of $15005$ .Alice comes up to Bob and says that she has added two numbers to get a result of $n$ . However, Bob knows that Alice adds in her own way. Help Bob find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of $n$ . Note that pairs $(a, b)$ and $(b, a)$ are considered different if $a \ne b$ .
输入格式
The input consists of multiple test cases. The first line contains an integer $t$ ( $1 \leq t \leq 1000$ ) — the number of test cases. The description of the test cases follows.
The only line of each test case contains an integer $n$ ( $2 \leq n \leq 10^9$ ) — the number Alice shows Bob.
The only line of each test case contains an integer $n$ ( $2 \leq n \leq 10^9$ ) — the number Alice shows Bob.
输出格式
For each test case, output one integer — the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of $n$ .
输入输出样例
输入 #1
5 100 12 8 2021 10000
输出 #1
9 4 7 44 99
In the first test case, when Alice evaluates any of the sums $1 + 9$ , $2 + 8$ , $3 + 7$ , $4 + 6$ , $5 + 5$ , $6 + 4$ , $7 + 3$ , $8 + 2$ , or $9 + 1$ , she will get a result of $100$ . The picture below shows how Alice evaluates $6 + 4$ :


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted