結果
問題 | No.129 お年玉(2) |
ユーザー | t8m8⛄️ |
提出日時 | 2015-03-12 09:02:34 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 673 ms / 5,000 ms |
コード長 | 3,861 bytes |
コンパイル時間 | 3,706 ms |
コンパイル使用メモリ | 75,196 KB |
実行使用メモリ | 56,028 KB |
最終ジャッジ日時 | 2023-08-18 17:05:51 |
合計ジャッジ時間 | 23,636 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 130 ms
54,828 KB |
testcase_01 | AC | 639 ms
55,484 KB |
testcase_02 | AC | 48 ms
47,892 KB |
testcase_03 | AC | 47 ms
49,680 KB |
testcase_04 | AC | 48 ms
49,712 KB |
testcase_05 | AC | 413 ms
55,504 KB |
testcase_06 | AC | 516 ms
55,432 KB |
testcase_07 | AC | 594 ms
55,900 KB |
testcase_08 | AC | 452 ms
55,332 KB |
testcase_09 | AC | 553 ms
55,424 KB |
testcase_10 | AC | 606 ms
55,596 KB |
testcase_11 | AC | 459 ms
55,596 KB |
testcase_12 | AC | 515 ms
55,468 KB |
testcase_13 | AC | 536 ms
55,684 KB |
testcase_14 | AC | 529 ms
55,504 KB |
testcase_15 | AC | 473 ms
56,028 KB |
testcase_16 | AC | 507 ms
55,840 KB |
testcase_17 | AC | 565 ms
55,676 KB |
testcase_18 | AC | 560 ms
55,540 KB |
testcase_19 | AC | 581 ms
55,832 KB |
testcase_20 | AC | 581 ms
55,540 KB |
testcase_21 | AC | 663 ms
55,876 KB |
testcase_22 | AC | 473 ms
55,508 KB |
testcase_23 | AC | 602 ms
55,616 KB |
testcase_24 | AC | 579 ms
55,856 KB |
testcase_25 | AC | 454 ms
55,572 KB |
testcase_26 | AC | 464 ms
55,624 KB |
testcase_27 | AC | 452 ms
55,804 KB |
testcase_28 | AC | 673 ms
55,652 KB |
testcase_29 | AC | 47 ms
49,656 KB |
testcase_30 | AC | 46 ms
49,420 KB |
testcase_31 | AC | 47 ms
49,768 KB |
testcase_32 | AC | 47 ms
49,540 KB |
testcase_33 | AC | 82 ms
51,964 KB |
testcase_34 | AC | 54 ms
50,012 KB |
testcase_35 | AC | 61 ms
50,320 KB |
testcase_36 | AC | 79 ms
50,236 KB |
testcase_37 | AC | 83 ms
52,348 KB |
testcase_38 | AC | 163 ms
54,708 KB |
testcase_39 | AC | 203 ms
54,956 KB |
testcase_40 | AC | 435 ms
55,464 KB |
testcase_41 | AC | 327 ms
55,540 KB |
testcase_42 | AC | 181 ms
55,032 KB |
testcase_43 | AC | 179 ms
55,252 KB |
testcase_44 | AC | 656 ms
55,576 KB |
testcase_45 | AC | 139 ms
55,144 KB |
testcase_46 | AC | 212 ms
55,048 KB |
testcase_47 | AC | 663 ms
55,476 KB |
testcase_48 | AC | 481 ms
55,756 KB |
ソースコード
//No.129 お年玉(2) import java.util.*; import java.io.*; import java.math.*; import static java.util.Arrays.*; import static java.lang.Math.*; public class No129 { static final InputStream in = System.in; static final PrintWriter out = new PrintWriter(System.out,false); static void solve(){ long n = nextLong(); int m = nextInt(); n -= n/1000/m*m*1000; n /= 1000; out.println(combination(m,n,new BigInteger("1000000000"))); } static BigInteger combination(long n, long r, BigInteger MOD) { BigInteger ret = BigInteger.ONE; for (int i=1; i<=n; i++) ret = ret.multiply(BigInteger.valueOf(i)); for (int i=1; i<=n-r; i++) ret = ret.divide(BigInteger.valueOf(i)); for (int i=1; i<=r; i++) ret = ret.divide(BigInteger.valueOf(i)); ret = ret.mod(MOD); return ret; } public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); solve(); out.flush(); long end = System.currentTimeMillis(); //trace(end-start + "ms"); in.close(); } static void trace(Object... o) { System.out.println(deepToString(o));} static final byte[] buf = new byte[1024]; static int ptr = 0; static int buflen = 0; static boolean hasNextByte() { if (ptr < buflen) return true; ptr = 0; try{ buflen = in.read(buf); }catch (IOException e) {e.printStackTrace();} if (buflen <= 0) return false; return true; } static int readByte() { if (hasNextByte()) return buf[ptr++]; else return -1;} static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} static void skip() { while(hasNextByte() && !isPrintableChar(buf[ptr])) ptr++;} static boolean hasNext() {skip(); return hasNextByte();} static String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } static long nextLong() { if (!hasNext()) throw new NoSuchElementException(); boolean minus = false; long num = readByte(); if(num == '-'){ num = 0; minus = true; }else if (num < '0' || '9' < num){ throw new NumberFormatException(); }else{ num -= '0'; } while(true){ int b = readByte(); if('0' <= b && b <= '9') num = num * 10 + (b - '0'); else if(b == -1 || !isPrintableChar(b)) return minus ? -num : num; else throw new NoSuchElementException(); } } static int nextInt() { long num = nextLong(); if (num < Integer.MIN_VALUE || Integer.MAX_VALUE < num) throw new NumberFormatException(); return (int)num; } static double nextDouble() { return Double.parseDouble(next()); } static char nextChar() { if (!hasNext()) throw new NoSuchElementException(); return (char)readByte(); } static String nextLine() { while (hasNextByte() && (buf[ptr] == '\n' || buf[ptr] == '\r')) ptr++; if (!hasNextByte()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (b != '\n' && b != '\r') { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } static int[] nextArrayInt(int n) { int[] a = new int[n]; for (int i=0; i<n; i++) a[i] = nextInt(); return a; } }