问题 C: Haitang and Math

内存限制:256 MB 时间限制:1 S
题面:传统 评测方式:Special Judge 上传者:
提交:7 通过:1

题目描述

Haitang defines the $\textstyle S(m)$ of a positive integer $\textstyle m$ as the sum of digits in $\textstyle m$.

For example, $\textstyle S(154)=1+5+4=10$, $\textstyle S(147)=1+4+7=12$.

Given a positive integer $\textstyle n$, count the number of positive integers $\textstyle m\le n$ such that $\textstyle n\bmod m=S(m)$.

输入格式

Each test contains multiple test cases. The first line contains an integer $\textstyle T$ ($\textstyle 1\leq T\leq 100$) — the number of test cases. The description of the test cases follows.

The first and only line of each test case contains an integer $\textstyle n$ ($\textstyle 1\leq n\leq 10^{12}$).

输出格式

For each test case, print one line containing an integer — the answer.

输入样例 复制

8
11
45
14
191
9810
20061130
20080520
998244353

输出样例 复制

1
3
0
3
17
10
3
15

分类标签