308311: CF1498A. GCD Sum
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
GCD Sum
题意翻译
$\operatorname{gcdSum(x)=}\gcd(x,\sum_{i=1}^ka_i)$ 其中 $a_i$ 表示 $x$ 的从左到右第 $i$ 位,$k$ 表示 $x$ 的位数。 例如 $\operatorname{gcdSum(762)}=\gcd(762,2+6+7)=\gcd(762,15)=3$ 给定一个 $n$,请你找到一个最小的整数 $x$ 满足: - $x\ge n$ - $\operatorname{gcdSum(x)}>1$题目描述
The $ \text{ $ gcdSum $ } $ of a positive integer is the $ gcd $ of that integer with its sum of digits. Formally, $ \text{ $ gcdSum $ }(x) = gcd(x, \text{ sum of digits of } x) $ for a positive integer $ x $ . $ gcd(a, b) $ denotes the greatest common divisor of $ a $ and $ b $ — the largest integer $ d $ such that both integers $ a $ and $ b $ are divisible by $ d $ . For example: $ \text{ $ gcdSum $ }(762) = gcd(762, 7 + 6 + 2)=gcd(762,15) = 3 $ . Given an integer $ n $ , find the smallest integer $ x \ge n $ such that $ \text{ $ gcdSum $ }(x) > 1 $ .输入输出格式
输入格式
The first line of input contains one integer $ t $ $ (1 \le t \le 10^4) $ — the number of test cases. Then $ t $ lines follow, each containing a single integer $ n $ $ (1 \le n \le 10^{18}) $ . All test cases in one test are different.
输出格式
Output $ t $ lines, where the $ i $ -th line is a single integer containing the answer to the $ i $ -th test case.
输入输出样例
输入样例 #1
3
11
31
75
输出样例 #1
12
33
75