結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー GrenacheGrenache
提出日時 2016-04-01 22:08:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 1,733 bytes
コンパイル時間 3,562 ms
コンパイル使用メモリ 79,096 KB
実行使用メモリ 54,872 KB
最終ジャッジ日時 2024-04-10 07:15:20
合計ジャッジ時間 4,626 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
54,784 KB
testcase_01 AC 155 ms
54,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main_yukicoder41 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Printer pr = new Printer(System.out);

		final int MOD = 1_000_000_009;

		int n = (int)(10_000_000_000L / 111111);

		long[] dp = new long[n + 1];
		dp[0] = 1;

		for (int j = 0; j <= 9; j++) {
			int tmp;
			if (j == 0) {
				tmp = 1;
			} else {
				tmp = j;
			}

			for (int i = tmp; i <= n; i++) {
				dp[i] = (dp[i - tmp] + dp[i]) % MOD;
			}
		}

		int t = sc.nextInt();
		for (int tcase = 0; tcase < t; tcase++) {
			long m = sc.nextLong();

			pr.println(dp[(int)(m / 111111)]);
		}

		pr.close();
        sc.close();
    }

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0