結果
問題 | No.129 お年玉(2) |
ユーザー | ki_ki33 |
提出日時 | 2015-01-17 00:02:18 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 226 ms / 5,000 ms |
コード長 | 1,639 bytes |
コンパイル時間 | 2,465 ms |
コンパイル使用メモリ | 92,296 KB |
実行使用メモリ | 58,820 KB |
最終ジャッジ日時 | 2023-08-18 16:28:43 |
合計ジャッジ時間 | 12,728 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 139 ms
55,576 KB |
testcase_01 | AC | 117 ms
55,728 KB |
testcase_02 | AC | 117 ms
56,268 KB |
testcase_03 | AC | 120 ms
55,880 KB |
testcase_04 | AC | 118 ms
55,804 KB |
testcase_05 | AC | 168 ms
57,624 KB |
testcase_06 | AC | 205 ms
58,820 KB |
testcase_07 | AC | 205 ms
58,408 KB |
testcase_08 | AC | 137 ms
55,912 KB |
testcase_09 | AC | 192 ms
58,656 KB |
testcase_10 | AC | 194 ms
58,716 KB |
testcase_11 | AC | 184 ms
58,640 KB |
testcase_12 | AC | 137 ms
55,784 KB |
testcase_13 | AC | 134 ms
55,744 KB |
testcase_14 | AC | 196 ms
58,452 KB |
testcase_15 | AC | 199 ms
58,244 KB |
testcase_16 | AC | 204 ms
58,416 KB |
testcase_17 | AC | 180 ms
58,404 KB |
testcase_18 | AC | 185 ms
58,468 KB |
testcase_19 | AC | 160 ms
58,488 KB |
testcase_20 | AC | 212 ms
58,744 KB |
testcase_21 | AC | 193 ms
58,296 KB |
testcase_22 | AC | 187 ms
58,136 KB |
testcase_23 | AC | 195 ms
58,636 KB |
testcase_24 | AC | 137 ms
55,928 KB |
testcase_25 | AC | 201 ms
58,028 KB |
testcase_26 | AC | 200 ms
58,384 KB |
testcase_27 | AC | 182 ms
58,016 KB |
testcase_28 | AC | 226 ms
58,712 KB |
testcase_29 | AC | 120 ms
55,788 KB |
testcase_30 | AC | 123 ms
56,008 KB |
testcase_31 | AC | 120 ms
57,932 KB |
testcase_32 | AC | 121 ms
55,804 KB |
testcase_33 | AC | 118 ms
55,796 KB |
testcase_34 | AC | 124 ms
55,608 KB |
testcase_35 | AC | 122 ms
55,936 KB |
testcase_36 | AC | 130 ms
55,908 KB |
testcase_37 | AC | 125 ms
55,772 KB |
testcase_38 | AC | 156 ms
57,840 KB |
testcase_39 | AC | 165 ms
58,712 KB |
testcase_40 | AC | 174 ms
58,228 KB |
testcase_41 | AC | 185 ms
58,168 KB |
testcase_42 | AC | 166 ms
58,092 KB |
testcase_43 | AC | 140 ms
55,564 KB |
testcase_44 | AC | 168 ms
58,048 KB |
testcase_45 | AC | 149 ms
56,268 KB |
testcase_46 | AC | 146 ms
56,008 KB |
testcase_47 | AC | 191 ms
58,364 KB |
testcase_48 | AC | 166 ms
57,972 KB |
ソースコード
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; } }