結果

問題 No.129 お年玉(2)
ユーザー uafr_csuafr_cs
提出日時 2015-08-06 19:54:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 601 ms / 5,000 ms
コード長 738 bytes
コンパイル時間 6,480 ms
コンパイル使用メモリ 78,548 KB
実行使用メモリ 458,984 KB
最終ジャッジ日時 2023-08-18 17:27:49
合計ジャッジ時間 21,750 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
79,792 KB
testcase_01 AC 601 ms
453,008 KB
testcase_02 AC 111 ms
53,736 KB
testcase_03 AC 111 ms
56,108 KB
testcase_04 AC 112 ms
55,824 KB
testcase_05 AC 338 ms
230,512 KB
testcase_06 AC 496 ms
360,956 KB
testcase_07 AC 545 ms
457,924 KB
testcase_08 AC 371 ms
267,768 KB
testcase_09 AC 449 ms
361,552 KB
testcase_10 AC 543 ms
453,600 KB
testcase_11 AC 373 ms
258,020 KB
testcase_12 AC 435 ms
359,400 KB
testcase_13 AC 454 ms
357,736 KB
testcase_14 AC 431 ms
358,140 KB
testcase_15 AC 410 ms
357,984 KB
testcase_16 AC 430 ms
361,604 KB
testcase_17 AC 536 ms
457,972 KB
testcase_18 AC 438 ms
359,388 KB
testcase_19 AC 532 ms
458,648 KB
testcase_20 AC 533 ms
457,896 KB
testcase_21 AC 575 ms
457,540 KB
testcase_22 AC 369 ms
271,612 KB
testcase_23 AC 563 ms
453,284 KB
testcase_24 AC 548 ms
458,984 KB
testcase_25 AC 369 ms
260,128 KB
testcase_26 AC 368 ms
263,984 KB
testcase_27 AC 373 ms
259,608 KB
testcase_28 AC 571 ms
457,808 KB
testcase_29 AC 108 ms
55,568 KB
testcase_30 AC 111 ms
55,956 KB
testcase_31 AC 107 ms
55,992 KB
testcase_32 AC 106 ms
55,596 KB
testcase_33 AC 122 ms
58,456 KB
testcase_34 AC 117 ms
55,984 KB
testcase_35 AC 120 ms
57,828 KB
testcase_36 AC 121 ms
57,656 KB
testcase_37 AC 124 ms
60,096 KB
testcase_38 AC 177 ms
114,792 KB
testcase_39 AC 205 ms
132,036 KB
testcase_40 AC 349 ms
244,740 KB
testcase_41 AC 260 ms
189,008 KB
testcase_42 AC 180 ms
114,768 KB
testcase_43 AC 182 ms
114,944 KB
testcase_44 AC 577 ms
453,940 KB
testcase_45 AC 160 ms
87,204 KB
testcase_46 AC 213 ms
131,416 KB
testcase_47 AC 574 ms
455,308 KB
testcase_48 AC 409 ms
357,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextLong();
		final int M = sc.nextInt();
		
		int[][] nCk = new int[M + 1][M + 1];
		nCk[0][0] = 1;
		for(int i = 0; i < M; i++){
			for(int j = 0; j <= i; j++){
				nCk[i + 1][j] += nCk[i][j];
				nCk[i + 1][j] %= 1000000000;
				nCk[i + 1][j + 1] += nCk[i][j];
				nCk[i + 1][j + 1] %= 1000000000;
			}
		}
		
		final long one_person = N / 1000 / M * 1000;
		final long rest = N - M * one_person;
		final int k = (int)(rest / 1000);
		
		System.out.println(nCk[M][k]);
		
		
	}
	
}
0