CF1907E.Good Triples

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Given a non-negative integer number nn (n≥0n \ge 0). Let's say a triple of non-negative integers (a,b,c)(a, b, c) is good if a+b+c=na + b + c = n, and digsum(a)+digsum(b)+digsum(c)=digsum(n)digsum(a) + digsum(b) + digsum(c) = digsum(n), where digsum(x)digsum(x) is the sum of digits of number xx.

For example, if n=26n = 26, then the pair (4,12,10)(4, 12, 10) is good, because 4+12+10=264 + 12 + 10 = 26, and (4)+(1+2)+(1+0)=(2+6)(4) + (1 + 2) + (1 + 0) = (2 + 6).

Your task is to find the number of good triples for the given number nn. The order of the numbers in a triple matters. For example, the triples (4,12,10)(4, 12, 10) and (10,12,4)(10, 12, 4) are two different triples.

给定一个非负整数 nn(n≥0n \ge 0)。称一个由非负整数组成的三元组 (a,b,c)(a, b, c) 是“好”的,当且仅当满足 a+b+c=na + b + c = n,且 digsum(a)+digsum(b)+digsum(c)=digsum(n)\mathrm{digsum}(a) + \mathrm{digsum}(b) + \mathrm{digsum}(c) = \mathrm{digsum}(n),其中 digsum(x)\mathrm{digsum}(x) 表示数字 xx 的各位数字之和。

例如,若 n=26n = 26,则三元组 (4,12,10)(4, 12, 10) 是“好”的,因为 4+12+10=264 + 12 + 10 = 26,且 (4)+(1+2)+(1+0)=(2+6)(4) + (1 + 2) + (1 + 0) = (2 + 6)。

你的任务是:对给定的数字 nn,求出“好”三元组的个数。三元组中数字的顺序是有区别的。例如,三元组 (4,12,10)(4, 12, 10) 和 (10,12,4)(10, 12, 4) 被视为两个不同的三元组。

输入格式

The first line of input contains a single integer tt (1≤t≤1041 \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 nn (0≤n≤1070 \le n \le 10^7).

输入的第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 表示测试用例的数量。随后是各测试用例的描述。

每个测试用例仅有一行,包含一个整数 nn(0≤n≤1070 \le n \le 10^7)。

输出格式

For each test case output one integer, the number of good triples for the given integer nn. Order of integers in a triple matters.

对于每个测试用例,输出一个整数,表示给定整数 nn 对应的“好三元组”的数量。三元组中整数的顺序是重要的。

输入输出样例

  • 输入#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, 0, 11), (0,1,10)(0, 1, 10), (0,10,1)(0, 10, 1), (0,11,0)(0, 11, 0), (1,0,10)(1, 0, 10), (1,10,0)(1, 10, 0), (10,0,1)(10, 0, 1), (10,1,0)(10, 1, 0), (11,0,0)(11, 0, 0).

In the second example, there is only one good triple (0,0,0)(0, 0, 0).

在第一个例子中,好的三元组为 (0,0,11)(0, 0, 11)、(0,1,10)(0, 1, 10)、(0,10,1)(0, 10, 1)、(0,11,0)(0, 11, 0)、(1,0,10)(1, 0, 10)、(1,10,0)(1, 10, 0)、(10,0,1)(10, 0, 1)、(10,1,0)(10, 1, 0)、(11,0,0)(11, 0, 0)。

在第二个例子中,仅有一个好的三元组 (0,0,0)(0, 0, 0)。

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

首页