結果

問題 No.129 お年玉(2)
ユーザー crazybbb3crazybbb3
提出日時 2017-01-30 22:08:20
言語 Java19
(openjdk 21)
結果
AC  
実行時間 621 ms / 5,000 ms
コード長 2,134 bytes
コンパイル時間 2,528 ms
コンパイル使用メモリ 75,484 KB
実行使用メモリ 56,952 KB
最終ジャッジ日時 2023-08-18 17:48:00
合計ジャッジ時間 14,026 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
52,636 KB
testcase_01 AC 621 ms
56,512 KB
testcase_02 AC 41 ms
49,716 KB
testcase_03 AC 40 ms
49,732 KB
testcase_04 AC 39 ms
49,788 KB
testcase_05 AC 273 ms
56,424 KB
testcase_06 AC 207 ms
56,220 KB
testcase_07 AC 371 ms
56,680 KB
testcase_08 AC 417 ms
56,656 KB
testcase_09 AC 200 ms
56,104 KB
testcase_10 AC 400 ms
56,620 KB
testcase_11 AC 242 ms
56,156 KB
testcase_12 AC 56 ms
50,804 KB
testcase_13 AC 49 ms
49,708 KB
testcase_14 AC 210 ms
56,668 KB
testcase_15 AC 198 ms
56,208 KB
testcase_16 AC 242 ms
56,404 KB
testcase_17 AC 158 ms
55,852 KB
testcase_18 AC 381 ms
56,952 KB
testcase_19 AC 495 ms
56,480 KB
testcase_20 AC 266 ms
54,448 KB
testcase_21 AC 166 ms
56,460 KB
testcase_22 AC 265 ms
56,280 KB
testcase_23 AC 379 ms
56,344 KB
testcase_24 AC 530 ms
56,644 KB
testcase_25 AC 225 ms
56,388 KB
testcase_26 AC 361 ms
56,740 KB
testcase_27 AC 282 ms
56,368 KB
testcase_28 AC 238 ms
56,688 KB
testcase_29 AC 40 ms
49,620 KB
testcase_30 AC 40 ms
49,508 KB
testcase_31 AC 39 ms
49,752 KB
testcase_32 AC 40 ms
49,728 KB
testcase_33 AC 41 ms
49,612 KB
testcase_34 AC 45 ms
49,696 KB
testcase_35 AC 40 ms
49,648 KB
testcase_36 AC 50 ms
49,740 KB
testcase_37 AC 45 ms
50,080 KB
testcase_38 AC 113 ms
55,984 KB
testcase_39 AC 109 ms
55,704 KB
testcase_40 AC 132 ms
55,640 KB
testcase_41 AC 204 ms
56,360 KB
testcase_42 AC 161 ms
55,776 KB
testcase_43 AC 58 ms
51,108 KB
testcase_44 AC 542 ms
56,284 KB
testcase_45 AC 117 ms
55,996 KB
testcase_46 AC 55 ms
51,104 KB
testcase_47 AC 465 ms
56,812 KB
testcase_48 AC 415 ms
56,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        long n = nl();
        long m = nl();

        n %= m * 1000;
        n /= 1000;

        BigInteger ans = BigInteger.ONE;
        for (int i = 0; i < n; i++) {
            BigInteger x = new BigInteger(String.valueOf(m - i));
            ans = ans.multiply(x);
        }
        for (int i = 1; i <= n; i++) {
            BigInteger x = new BigInteger(String.valueOf(i));
            ans = ans.divide(x);
        }
        ans = ans.mod(new BigInteger("1000000000"));

        out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0