結果
問題 | No.3070 Collecting Coins Speedrun 2 |
ユーザー |
![]() |
提出日時 | 2025-03-21 22:03:03 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 556 ms / 2,000 ms |
コード長 | 944 bytes |
コンパイル時間 | 3,696 ms |
コンパイル使用メモリ | 79,752 KB |
実行使用メモリ | 51,344 KB |
最終ジャッジ日時 | 2025-03-21 22:03:20 |
合計ジャッジ時間 | 14,264 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] c = new int[n]; for (int i = 0; i < n; i++) { c[i] = sc.nextInt(); } sc.close(); int m = 0; int z = 0; int p = 0; for (int i = 0; i < n; i++) { if (c[i] < 0) { m++; } else if (c[i] == 0) { z++; } else { p++; } } int mod = 998244353; int a = 1; if (m > 0 && p > 0) a++; int b = 1; if (m > 0) b++; if (p > 0) b++; if (z == 0) b = 1; long v1 = power(2, Math.max(m - 1, 0), mod); long v2 = power(2, Math.max(p - 1, 0), mod); long ans = a * v1 * b % mod * v2 % mod; System.out.println(ans); } static long power(long x, long n, int m) { if (n == 0) { return 1; } long val = power(x, n / 2, m); val = val * val % m; if (n % 2 == 1) { x %= m; val = val * x % m; } return val; } }