← 返回题目列表

Codeforces · 1455/A

A. 奇怪的功能

中文机器翻译题面 查看原题

Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes.例如,$$$f(321) = 123$$$、$$$f(120) = 21$$$、$$$f(1000000) = 1$$$、$$$f(111) = 111$$$。

让我们定义另一个函数 $$$g(x) = \dfrac{x}{f(f(x))}$$$ ($$$x$$$ 也是一个正整数)。

Your task is the following: for the given positive integer $$$n$$$, calculate the number of different values of $$$g(x)$$$ among all numbers $$$x$$$ such that $$$1 \le x \le n$$$.

输入

第一行包含一个整数 $$$t$$$ ($$$1 \le t \le 100$$$) — 测试用例的数量。

每个测试用例由一行组成,其中包含一个整数 $$$n$$$ ($$$1 \le n < 10^{100}$$$)。该整数不带前导零。

输出

For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.

示例

输入 #1

5
4
37
998244353
1000000007
12345678901337426966631415

输出 #1

1
2
9
10
26

注意

该示例的前两个测试用例的说明:

1. 如果 $$$n = 4$$$,则对于每个整数 $$$x$$$,使得 $$$1 \le x \le n$$$,$$$\dfrac{x}{f(f(x))} = 1$$$;
2. if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)) = 23$$$,$$$\dfrac{x}{f(f(x))} = 1$$$);对于 $$$x$$$ 的其他值,$$$\dfrac{x}{f(f(x))} = 10$$$(例如,如果 $$$x = 30$$$、$$$f(f(x)) = 3$$$、$$$\dfrac{x}{f(f(x))} = 10$$$)。因此,$$$g(x)$$$ 有两个不同的值。