Codeforces Round 1092 (Unrated, Div. 1, Based on THUPC 2026 — Finals)
B
RReeppeettiittiioonn
Codeforces
2000
原题
← AC →
翻译中…

As a girl born on November 11th (or 11/11), SS loves repetition. For example, her favorite English word is bookkeeper, her favorite letter is W (double-u, double vé, or whatever you call it), her favorite animals are the cat (kitten!) and the rabbit (bunny!), her favorite programming language is C*++, her favorite parser is LL(1), her favorite optimization algorithm is branch and bound (BB), her favorite unit is millimeter (mm), her favorite game is LLLL, and her favorite winning hand in Mahjong is Seven Pairs. She plans to release her new songs "Silent-night Satellite" and "Siesta Stella" soon, so she wants to select a "prett*y" number to decorate the cover of her new songs.

翻译中…

SS observes this world from a higher perspective, which means she considers an integer concurrently in all standard positional numeral systems, starting from the binary numeral system. SS then calls a positive integer $n$ $(b, p)$-tidy (with $b,p\ge 2$) if and only if:

翻译中…
  • In base-$b$ representation, $n$ is represented as $\overline{d_{k\cdot p-1} d_{k\cdot p-2}\ldots d_1 d_0}$ for some positive integer $k$ and integers $0\le d_i \lt b$, such that for each $0\le i \lt k$, $d_{i\cdot p}=d_{i\cdot p+1}=\cdots=d_{(i+1)\cdot p-1}$.
翻译中…

For example, $2233$ and $3355$ are $(10,2)$-tidy, $1111$ is both $(10,2)$-tidy and $(10,4)$-tidy, and $6\,737\,151=(66\textrm{CCFF})_{16}$ is $(16,2)$-tidy. Furthermore, SS defines the tidiness of a positive integer $n$ as the number of ordered pairs $(b, p)$ such that $n$ is $(b, p)$-tidy.

翻译中…

SS has given you an integer $n$. Your task is to determine the tidiness of $n$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). The description of the test cases follows.

翻译中…

The only line of each test case contains a single integer $n$ ($1\le n\le 10^{12}$) — the integer SS has given you.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^{12}$.

翻译中…

Output

翻译中…

For each test case, output a single integer — the tidiness of $n$.

翻译中…

Note

翻译中…

In the third test case, $115={(55)}_{22}={(11)}_{114}$. Therefore, the tidiness of $115$ is $2$.

翻译中…

In the fourth test case, $1111$ is $(10, 2)$-tidy, $(10, 4)$-tidy, $(100, 2)$-tidy, and $(1110, 2)$-tidy.

翻译中…

样例

Input #1
10
1
2
115
1111
2233
3355
191970
6737151
102934760424
618111100000
Output #1
0
0
2
4
5
5
24
9
17
144
InputCopy OutputCopy
题目信息
题号
2215B
时间限制
2.5 s
内存限制
512 MB
标签
二分
暴力
模拟
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。