結果

問題 No.129 お年玉(2)
ユーザー ki_ki33ki_ki33
提出日時 2015-01-17 00:02:18
言語 Java19
(openjdk 19.0.1)
結果
AC  
実行時間 217 ms / 5,000 ms
コード長 1,639 bytes
コンパイル時間 1,888 ms
実行使用メモリ 42,976 KB
最終ジャッジ日時 2023-01-04 19:16:30
合計ジャッジ時間 11,386 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
38,568 KB
testcase_01 AC 103 ms
37,656 KB
testcase_02 AC 97 ms
37,596 KB
testcase_03 AC 100 ms
37,492 KB
testcase_04 AC 105 ms
37,456 KB
testcase_05 AC 141 ms
39,408 KB
testcase_06 AC 198 ms
42,528 KB
testcase_07 AC 182 ms
42,976 KB
testcase_08 AC 126 ms
38,540 KB
testcase_09 AC 179 ms
42,724 KB
testcase_10 AC 189 ms
42,032 KB
testcase_11 AC 191 ms
42,620 KB
testcase_12 AC 121 ms
38,248 KB
testcase_13 AC 111 ms
37,788 KB
testcase_14 AC 184 ms
42,452 KB
testcase_15 AC 198 ms
42,512 KB
testcase_16 AC 194 ms
42,544 KB
testcase_17 AC 175 ms
42,004 KB
testcase_18 AC 186 ms
42,028 KB
testcase_19 AC 147 ms
40,584 KB
testcase_20 AC 198 ms
42,560 KB
testcase_21 AC 192 ms
42,236 KB
testcase_22 AC 172 ms
42,036 KB
testcase_23 AC 194 ms
42,812 KB
testcase_24 AC 121 ms
38,516 KB
testcase_25 AC 202 ms
42,712 KB
testcase_26 AC 155 ms
41,840 KB
testcase_27 AC 173 ms
42,232 KB
testcase_28 AC 217 ms
42,772 KB
testcase_29 AC 97 ms
37,304 KB
testcase_30 AC 101 ms
37,352 KB
testcase_31 AC 99 ms
37,596 KB
testcase_32 AC 102 ms
37,364 KB
testcase_33 AC 95 ms
37,200 KB
testcase_34 AC 104 ms
37,616 KB
testcase_35 AC 101 ms
37,584 KB
testcase_36 AC 108 ms
37,964 KB
testcase_37 AC 109 ms
37,572 KB
testcase_38 AC 143 ms
39,972 KB
testcase_39 AC 126 ms
39,600 KB
testcase_40 AC 157 ms
42,580 KB
testcase_41 AC 171 ms
42,132 KB
testcase_42 AC 131 ms
39,660 KB
testcase_43 AC 122 ms
38,372 KB
testcase_44 AC 169 ms
40,816 KB
testcase_45 AC 127 ms
39,172 KB
testcase_46 AC 121 ms
38,568 KB
testcase_47 AC 184 ms
42,048 KB
testcase_48 AC 128 ms
39,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	public static final int C =  1000000007;
	static final int CY = 1000000000;
	//static boolean MAP[][];
	static long N;
	static long M;
	static int MAX = -1;
	//static int tic[][];
	static int MAP[][];
	//static int max;
	static int DP[][][];
	static int ST[][];
	//static int p[];
	//static ArrayList<HashSet<Integer>> al;
	static TreeMap<Integer, ArrayList<Integer>> hm;
	//static ArrayList<Integer> al;
	//static int a[][];
	//static char[][] ch;
	//static ArrayList<HashMap<Long, Long>> al;
	//static String a[];
	//static String str;

	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		BufferedInputStream bs = new BufferedInputStream(System.in);
		Scanner sc = new Scanner(bs);
		
		N = sc.nextLong()/1000;
		M =sc.nextInt();
		

		
		BigInteger bi = new BigInteger("0");
		
		long ans = 0;
		
		long let = N%M;
		
		//for (int i=1; i <= let; i++) {
			bi = bi.add(calcCombination(M, let));
		//}
		if (bi.equals(new BigInteger("0"))) {
			bi = new BigInteger("1");
		}
		System.out.println(bi.mod(new BigInteger(CY+"")));


	}
	

	/**
	 * aCbを計算して返す
	 */
	static BigInteger calcCombination(long a, long b) {
		BigInteger rtn = new BigInteger("1");
		long k = Math.min(b, a-b);
		
		
		if (k < 0) {
			return new BigInteger("0");
		}
		for (long i=1; i <= k;i++) {
			
			rtn = rtn.multiply(new BigInteger((a-(i-1))+""));
	
			rtn = rtn.divide(new BigInteger(i + ""));
		}
		return rtn;
	}

}
0