AT_ndpc2026_p.LIS

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

For a positive integer nn, define f(n)f(n) as follows:

  • Let nn have dd digits in decimal representation. Define a sequence A=(A1,…,Ad)A = (A_1, \dots, A_d) of length dd as follows:
    • AiA_i is the ii-th digit from the left in the decimal representation of nn.
  • Let f(n)f(n) be the length of the longest strictly increasing subsequence of AA.

For example, f(347)=3f(347) = 3, f(1192)=2f(1192) = 2, f(10123456789)=10f(10123456789) = 10, and f(11111)=1f(11111) = 1.

You are given a positive integer NN.
Count the number of positive integers xx such that by repeatedly applying the operation x→x+f(x)x \to x + f(x) zero or more times, you can obtain NN.

You are given TT test cases. Solve each of them.

对于正整数 nn,定义函数 f(n)f(n) 如下:

  • 设 nn 的十进制表示包含 dd 位数字。定义一个长度为 dd 的序列 A=(A1,…,Ad)A = (A_1, \dots, A_d):
    • AiA_i 是 nn 的十进制表示中从左往右第 ii 位数字。
  • 令 f(n)f(n) 为序列 AA 的最长严格递增子序列的长度。

例如,f(347)=3f(347) = 3,f(1192)=2f(1192) = 2,f(10123456789)=10f(10123456789) = 10,以及 f(11111)=1f(11111) = 1。

给定一个正整数 NN。
请统计满足如下条件的正整数 xx 的个数:通过将操作 x→x+f(x)x \to x + f(x) 执行零次或多次,可以得到 NN。

你将收到 TT 组测试用例,请对每组用例求解。

输入格式

The input is given from standard input in the following format:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

Each test case is given in the following format:

NN

输入从标准输入中按以下格式给出:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

每个测试用例按以下格式给出:

NN

输出格式

Print TT lines. On the ii-th line, output the answer for the ii-th test case.

输出 TT 行。第 ii 行输出第 ii 个测试用例的答案。

输入输出样例

  • 输入#1

    6
    7
    110
    1000000000000000000
    567784738694904180
    555056967895592095
    942135357890920474

    输出#1

    7
    5
    1000000000000000000
    23644
    22551
    60795

说明/提示

Sample 1 Explanation:
For example, in the second test case, starting from x=102x = 102 and repeatedly applying the operation x→x+f(x)x \to x + f(x):

  • 102→104→106→108→110102 \to 104 \to 106 \to 108 \to 110

we can obtain N=110N = 110. The only values of xx satisfying the condition are x=102,104,106,108,110x = 102, 104, 106, 108, 110, so there are 55 in total.

Constraints

  • 1≤T≤2×1041 \leq T \leq 2 \times 10^4
  • 1≤N≤10181 \leq N \leq 10^{18}
  • All input values are integers

样例 1 解释:
例如,在第二个测试用例中,从 x=102x = 102 开始,反复执行操作 x→x+f(x)x \to x + f(x):

  • 102→104→106→108→110102 \to 104 \to 106 \to 108 \to 110

即可得到 N=110N = 110。满足条件的 xx 值仅有 x=102, 104, 106, 108, 110x = 102,\, 104,\, 106,\, 108,\, 110,共 55 个。

约束条件

  • 1≤T≤2×1041 \leq T \leq 2 \times 10^4
  • 1≤N≤10181 \leq N \leq 10^{18}
  • 所有输入值均为整数

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

首页