結果

問題 No.129 お年玉(2)
ユーザー Grenache
提出日時 2015-12-28 23:56:20
言語 Java
(openjdk 23)
結果
AC  
実行時間 432 ms / 5,000 ms
コード長 673 bytes
コンパイル時間 8,354 ms
コンパイル使用メモリ 74,424 KB
実行使用メモリ 41,704 KB
最終ジャッジ日時 2024-11-28 00:15:26
合計ジャッジ時間 18,951 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder129 {

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

        final int MOD = 1_000_000_000;

        long n = sc.nextLong() / 1000;
        int m = sc.nextInt();

        int a = (int)(n % m);

        int[][] p = new int[2][m + 1];
        for (int i = 0; i <= m; i++) {
        	for (int j = 0; j <= i; j++) {
        		if (j == 0 || j == i) {
        			p[i % 2][j] = 1;
        		} else {
        			p[i % 2][j] = (p[(i + 1) % 2][j - 1] + p[(i + 1) % 2][j]) % MOD;
        		}
        	}
        }

        System.out.println(p[m % 2][a]);

        sc.close();
    }
}
0