結果
問題 | No.2527 H and W |
ユーザー | ks2m |
提出日時 | 2023-11-03 21:34:43 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 126 ms / 2,000 ms |
コード長 | 1,808 bytes |
コンパイル時間 | 2,723 ms |
コンパイル使用メモリ | 78,324 KB |
実行使用メモリ | 72,184 KB |
最終ジャッジ日時 | 2023-11-03 21:34:51 |
合計ジャッジ時間 | 6,910 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 96 ms
71,824 KB |
testcase_01 | AC | 97 ms
71,868 KB |
testcase_02 | AC | 98 ms
71,824 KB |
testcase_03 | AC | 97 ms
71,340 KB |
testcase_04 | AC | 115 ms
71,888 KB |
testcase_05 | AC | 113 ms
69,844 KB |
testcase_06 | AC | 126 ms
72,184 KB |
testcase_07 | AC | 97 ms
71,856 KB |
testcase_08 | AC | 105 ms
71,536 KB |
testcase_09 | AC | 96 ms
71,844 KB |
testcase_10 | AC | 97 ms
71,844 KB |
testcase_11 | AC | 119 ms
72,040 KB |
testcase_12 | AC | 115 ms
71,444 KB |
testcase_13 | AC | 114 ms
71,528 KB |
testcase_14 | AC | 102 ms
71,812 KB |
testcase_15 | AC | 115 ms
71,820 KB |
testcase_16 | AC | 97 ms
71,864 KB |
testcase_17 | AC | 102 ms
71,848 KB |
testcase_18 | AC | 98 ms
71,344 KB |
testcase_19 | AC | 101 ms
71,856 KB |
testcase_20 | AC | 99 ms
71,840 KB |
testcase_21 | AC | 100 ms
71,848 KB |
testcase_22 | AC | 97 ms
71,828 KB |
testcase_23 | AC | 97 ms
71,836 KB |
testcase_24 | AC | 98 ms
71,340 KB |
testcase_25 | AC | 109 ms
71,328 KB |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int h = Integer.parseInt(sa[0]); int w = Integer.parseInt(sa[1]); long k = Long.parseLong(sa[2]); br.close(); int mod = 998244353; List<Long> list = divList(k); Kaijou kai = new Kaijou(1000000, mod); long ans = 0; for (long x : list) { if (x > h) { continue; } long y = k / x; if (y > w) { continue; } long v1 = kai.comb(h, (int) x); long v2 = kai.comb(w, (int) y); long v = v1 * v2 % mod; ans += v; } ans %= mod; System.out.println(ans); } static List<Long> divList(long n) { List<Long> list = new ArrayList<>(); long end = (long) Math.sqrt(n); for (int i = 1; i <= end; i++) { if (n % i == 0) { list.add((long) i); } } int i = end * end == n ? list.size() - 2 : list.size() - 1; for ( ; i >= 0; i--) { list.add(n / list.get(i)); } return list; } static class Kaijou { long[] p, pi; int m; public Kaijou(int n, int mod) { n++; m = mod; p = new long[n]; pi = new long[n]; p[0] = 1; pi[0] = 1; for (int i = 1; i < n; i++) { p[i] = p[i - 1] * i % m; } pi[n - 1] = BigInteger.valueOf(p[n - 1]) .modInverse(BigInteger.valueOf(m)).longValue(); for (int i = n - 1; i > 1; i--) { pi[i - 1] = pi[i] * i % m; } } public long comb(int n, int r) { if (n < r) return 0; return p[n] * pi[r] % m * pi[n - r] % m; } public long perm(int n, int r) { if (n < r) return 0; return p[n] * pi[n - r] % m; } } }