UVa 1583 Digit Generator
1642 ワード
水の問題はJAVAに熟知してします
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
final int maxn = 100000 + 9;
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();
int[] a = new int[2 * maxn];
for (int i = 0; i < maxn; i++) {
int x = i;
int s = x;
while (x > 0) {
s += (x % 10);
x /= 10;
}
if (a[s] > 0) continue;
a[s] = i;
}
while (t-- > 0) {
int n = cin.nextInt();
System.out.println(a[n]);
}
}
}