結果

問題 No.2141 Enumeratest
ユーザー tentententen
提出日時 2023-03-03 08:25:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 2,120 bytes
コンパイル時間 5,254 ms
コンパイル使用メモリ 82,804 KB
実行使用メモリ 53,544 KB
最終ジャッジ日時 2023-10-18 00:48:01
合計ジャッジ時間 10,921 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
53,428 KB
testcase_01 AC 56 ms
53,432 KB
testcase_02 AC 63 ms
53,428 KB
testcase_03 AC 84 ms
53,440 KB
testcase_04 AC 69 ms
53,460 KB
testcase_05 AC 55 ms
53,432 KB
testcase_06 AC 54 ms
53,436 KB
testcase_07 AC 57 ms
53,428 KB
testcase_08 AC 68 ms
53,544 KB
testcase_09 AC 63 ms
52,372 KB
testcase_10 AC 68 ms
53,384 KB
testcase_11 AC 70 ms
53,436 KB
testcase_12 AC 59 ms
52,452 KB
testcase_13 AC 70 ms
53,444 KB
testcase_14 AC 70 ms
53,448 KB
testcase_15 AC 68 ms
53,452 KB
testcase_16 AC 69 ms
53,436 KB
testcase_17 AC 68 ms
53,444 KB
testcase_18 AC 64 ms
53,424 KB
testcase_19 AC 69 ms
53,468 KB
testcase_20 AC 67 ms
53,444 KB
testcase_21 AC 67 ms
53,444 KB
testcase_22 AC 64 ms
53,428 KB
testcase_23 AC 63 ms
53,444 KB
testcase_24 AC 70 ms
53,444 KB
testcase_25 AC 76 ms
53,368 KB
testcase_26 AC 56 ms
53,420 KB
testcase_27 AC 66 ms
53,420 KB
testcase_28 AC 64 ms
53,424 KB
testcase_29 AC 60 ms
53,432 KB
testcase_30 AC 68 ms
53,444 KB
testcase_31 AC 69 ms
53,420 KB
testcase_32 AC 68 ms
53,440 KB
testcase_33 AC 66 ms
53,424 KB
testcase_34 AC 70 ms
53,444 KB
testcase_35 AC 55 ms
53,432 KB
testcase_36 AC 66 ms
53,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    static final int MOD = 998244353;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int div = m / n;
        int mod = m % n;
        long ans = fact(m) * pow(pow(fact(div) , n - mod) * pow(fact(div + 1), mod) % MOD, MOD - 2) % MOD;
        System.out.println(ans);
    }
    
    static long pow(long x, int p) {
        if (p == 0) {
            return 1;
        } else if (p % 2 == 0) {
            return pow(x * x % MOD, p / 2);
        } else {
            return pow(x, p - 1) * x % MOD;
        }
    }
    
    static long fact(int x) {
        long ans = 1;
        for (int i = 1; i <= x; i++) {
            ans *= i;
            ans %= MOD;
        }
        return ans;
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0