CF1567C.Carrying Conundrum

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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+29762039 + 2976 would be as shown:

However, Alice evaluates it as shown:

In particular, this is what she does:

  • add 99 and 66 to make 1515, and carry the 11 to the column two columns to the left, i. e. to the column "00 99";
  • add 33 and 77 to make 1010 and carry the 11 to the column two columns to the left, i. e. to the column "22 22";
  • add 11, 00, and 99 to make 1010 and carry the 11 to the column two columns to the left, i. e. to the column above the plus sign;
  • add 11, 22 and 22 to make 55;
  • add 11 to make 11.

Thus, she ends up with the incorrect result of 1500515005.

Alice comes up to Bob and says that she has added two numbers to get a result of nn. 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 nn. Note that pairs (a,b)(a, b) and (b,a)(b, a) are considered different if a≠ba \ne b.

爱丽丝刚刚学会了加法。然而,她尚未完全掌握“进位”的概念——她不是将进位加到左边相邻的数位上,而是加到左边第二个数位上。

例如,按照常规方法计算 2039+29762039 + 2976 的过程如下所示:

但爱丽丝的计算方式如下所示:

具体而言,她的操作如下:

  • 将 99 和 66 相加得 1515,并将进位 11 加到左边第二个数位上,即加到 "00 99" 所在的数位;
  • 将 33 和 77 相加得 1010,并将进位 11 加到左边第二个数位上,即加到 "22 22" 所在的数位;
  • 将进位 11、00 和 99 相加得 1010,并将进位 11 加到左边第二个数位上,即加到加号上方的数位;
  • 将进位 11、22 和 22 相加得 55;
  • 最后单独写下进位 11。

因此,她得到了错误的结果 1500515005。

爱丽丝找到鲍勃,声称自己将两个数相加得到了结果 nn。但鲍勃知道爱丽丝使用的是她自己的加法方式。请帮助鲍勃找出有多少个有序正整数对 (a,b)(a, b),使得当爱丽丝用她的方式将 aa 和 bb 相加时,结果恰好为 nn。注意:若 a≠ba \ne b,则 (a,b)(a, b) 和 (b,a)(b, a) 被视为不同的数对。

输入格式

The input consists of multiple test cases. The first line contains an integer tt (1≤t≤10001 \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 nn (2≤n≤1092 \leq n \leq 10^9) — the number Alice shows Bob.

输入包含多个测试用例。第一行包含一个整数 tt(1≤t≤10001 \leq t \leq 1000),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例仅有一行,包含一个整数 nn(2≤n≤1092 \leq n \leq 10^9),即爱丽丝展示给鲍勃的数字。

输出格式

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 nn.

对于每个测试用例,输出一个整数——满足条件的正整数有序对的数量,使得爱丽丝将它们相加后得到结果 nn。

输入输出样例

  • 输入#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+91 + 9, 2+82 + 8, 3+73 + 7, 4+64 + 6, 5+55 + 5, 6+46 + 4, 7+37 + 3, 8+28 + 2, or 9+19 + 1, she will get a result of 100100. The picture below shows how Alice evaluates 6+46 + 4:

在第一个测试用例中,当爱丽丝计算任意一个和式 1+91 + 9、2+82 + 8、3+73 + 7、4+64 + 6、5+55 + 5、6+46 + 4、7+37 + 3、8+28 + 2 或 9+19 + 1 时,她都会得到结果 100100。下图展示了爱丽丝如何计算 6+46 + 4:

输入解题思路,AI测评打分。不知道怎么写?

首页