結果
問題 | No.2807 Have Another Go (Easy) |
ユーザー | tenten |
提出日時 | 2024-07-17 11:20:22 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 235 ms / 3,000 ms |
コード長 | 2,194 bytes |
コンパイル時間 | 2,962 ms |
コンパイル使用メモリ | 88,532 KB |
実行使用メモリ | 71,640 KB |
最終ジャッジ日時 | 2024-07-17 11:20:35 |
合計ジャッジ時間 | 12,591 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 82 ms
51,160 KB |
testcase_01 | AC | 193 ms
68,980 KB |
testcase_02 | AC | 180 ms
63,500 KB |
testcase_03 | AC | 181 ms
58,684 KB |
testcase_04 | AC | 133 ms
55,996 KB |
testcase_05 | AC | 190 ms
65,368 KB |
testcase_06 | AC | 181 ms
66,944 KB |
testcase_07 | AC | 142 ms
52,576 KB |
testcase_08 | AC | 166 ms
56,328 KB |
testcase_09 | AC | 158 ms
56,444 KB |
testcase_10 | AC | 144 ms
58,240 KB |
testcase_11 | AC | 201 ms
69,644 KB |
testcase_12 | AC | 206 ms
69,564 KB |
testcase_13 | AC | 200 ms
69,532 KB |
testcase_14 | AC | 223 ms
69,460 KB |
testcase_15 | AC | 199 ms
69,400 KB |
testcase_16 | AC | 227 ms
71,088 KB |
testcase_17 | AC | 199 ms
69,616 KB |
testcase_18 | AC | 197 ms
69,600 KB |
testcase_19 | AC | 205 ms
69,532 KB |
testcase_20 | AC | 200 ms
71,328 KB |
testcase_21 | AC | 195 ms
69,620 KB |
testcase_22 | AC | 198 ms
69,660 KB |
testcase_23 | AC | 206 ms
69,620 KB |
testcase_24 | AC | 196 ms
69,536 KB |
testcase_25 | AC | 220 ms
69,524 KB |
testcase_26 | AC | 202 ms
69,484 KB |
testcase_27 | AC | 195 ms
71,640 KB |
testcase_28 | AC | 197 ms
69,544 KB |
testcase_29 | AC | 204 ms
69,740 KB |
testcase_30 | AC | 235 ms
69,620 KB |
testcase_31 | AC | 91 ms
51,612 KB |
testcase_32 | AC | 85 ms
51,156 KB |
testcase_33 | AC | 94 ms
51,544 KB |
testcase_34 | AC | 81 ms
51,124 KB |
testcase_35 | AC | 89 ms
51,360 KB |
testcase_36 | AC | 96 ms
51,740 KB |
testcase_37 | AC | 86 ms
51,104 KB |
testcase_38 | AC | 114 ms
52,112 KB |
testcase_39 | AC | 82 ms
51,244 KB |
testcase_40 | AC | 105 ms
51,960 KB |
testcase_41 | AC | 115 ms
52,160 KB |
testcase_42 | AC | 111 ms
52,384 KB |
testcase_43 | AC | 116 ms
52,204 KB |
testcase_44 | AC | 107 ms
52,000 KB |
testcase_45 | AC | 98 ms
51,868 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.function.*; 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 k = sc.nextInt(); long[] dp = new long[n * 2 + 7]; dp[0] = 1; for (int i = 0; i < n * 2; i++) { for (int j = 1; j <= 6; j++) { dp[i + j] += dp[i]; dp[i + j] %= MOD; } } long[] fp = new long[n * 2 + 7]; for (int i = 0; i < 6; i++) { fp[n * 2 + i] = 1; } for (int i = n * 2 + 5; i > 0; i--) { for (int j = 1; j <= 6; j++) { if (i - j >= 0 && i - j < n * 2) { fp[i - j] += fp[i]; fp[i - j] %= MOD; } } } String result = IntStream.range(0, k).mapToObj(i -> { int x = sc.nextInt(); long ans = ((dp[x] * fp[x] % MOD + dp[x + n] * fp[x + n] % MOD) % MOD + MOD - dp[x] * dp[n] % MOD * fp[x + n] % MOD) % MOD; return String.valueOf(ans); }).collect(Collectors.joining("\n")); System.out.println(result); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }