308738: CF1567C. Carrying Conundrum

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Carrying Conundrum

题意翻译

Alice 刚学会加法。不幸的是,她并没有完全掌握进位——不同于正常方法中的满十向其**前一位**进位,Alice 满十向其**前两位**进位。 例如,按照正常方式,$2039+2976$ 是这么算的: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1567C/7f811803128f9de09a9d354d6ba38f6c979516bb.png) 而 Alice 是这么算的: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1567C/83982f3a368c4bf27357d999f4274a4bb752e11c.png) 因此,Alice 算出了一个显然错误的答案:$15005$。 有一次,Alice 算完后对 Bob 说,自己算出的结果为 $n$。然而,Bob 知道她用的是上面那种错误的方法进行加法运算的。因此,他现在想知道,可能使得 Alice 算出的结果为 $n$ 的数对 $(a,b)$ 一共有多少个。 请注意,**如果 $a\neq b$,$(a,b)$ 和 $(b,a)$ 将会认做是两个不同的数对,在统计个数的时候记为 $2$ 个**。 数据范围: - $t$ 组数据,$1\leqslant t\leqslant 1000$。 - $2\leqslant n\leqslant 10^9$。 Translated by Eason_AC 2021.9.6

题目描述

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: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1567C/7f811803128f9de09a9d354d6ba38f6c979516bb.png)However, Alice evaluates it as shown: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1567C/83982f3a368c4bf27357d999f4274a4bb752e11c.png)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.

输出格式


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 $ : ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1567C/b16910e4b25eab78326b49caad3574b10b90fef3.png)

Input

题意翻译

Alice 刚学会加法。不幸的是,她并没有完全掌握进位——不同于正常方法中的满十向其**前一位**进位,Alice 满十向其**前两位**进位。 例如,按照正常方式,$2039+2976$ 是这么算的: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1567C/7f811803128f9de09a9d354d6ba38f6c979516bb.png) 而 Alice 是这么算的: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1567C/83982f3a368c4bf27357d999f4274a4bb752e11c.png) 因此,Alice 算出了一个显然错误的答案:$15005$。 有一次,Alice 算完后对 Bob 说,自己算出的结果为 $n$。然而,Bob 知道她用的是上面那种错误的方法进行加法运算的。因此,他现在想知道,可能使得 Alice 算出的结果为 $n$ 的数对 $(a,b)$ 一共有多少个。 请注意,**如果 $a\neq b$,$(a,b)$ 和 $(b,a)$ 将会认做是两个不同的数对,在统计个数的时候记为 $2$ 个**。 数据范围: - $t$ 组数据,$1\leqslant t\leqslant 1000$。 - $2\leqslant n\leqslant 10^9$。 Translated by Eason_AC 2021.9.6

加入题单

上一题 下一题 算法标签: