本文共 1352 字,大约阅读时间需要 4 分钟。
Input
Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case takes one line containing an integer N, 1 ≤ N ≤ 100, 000.Output
Your program is to write to standard output. Print exactly one line for each test case. The line is to contain a generator of N for each test case. If N has multiple generators, print the smallest. If N does not have any generators, print ‘0’. Sample Input 3 216 121 2005 Sample Output 198 0 1979#includeusing namespace std;int main(){ int x[100050]{ 0 }, y; for (int i = 1; i < 100050; i++) { int m = i, n = i; while (m > 0) { n += m % 10; m /= 10; } if (x[n] == 0) x[n] = i; } cin >> y; while (y--) { int k; cin >> k; cout << x[k] << endl; } return 0;}
转载地址:http://mgyof.baihongyu.com/