結果
| 問題 |
No.3070 Collecting Coins Speedrun 2
|
| コンテスト | |
| ユーザー |
鴨志田卓
|
| 提出日時 | 2025-05-10 05:11:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 1,304 bytes |
| コンパイル時間 | 2,024 ms |
| コンパイル使用メモリ | 196,092 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-05-10 05:11:43 |
| 合計ジャッジ時間 | 4,037 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘void fileIO(std::string)’:
main.cpp:5:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
5 | freopen((s + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:6:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | freopen((s + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fileIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
using i64 = long long;
const int N = 1e5 + 10, P = 998244353;
int qpow(int b, int k) {
int ret = 1;
while(k > 0) {
if(k & 1) ret = ret * (i64)b % P;
b = (i64)b * b % P;
k >>= 1;
}
return ret;
}
int inv[N], fact[N], invFact[N];
int C(int n, int m) {
if(m > n || m < 0) return 0;
return fact[n] * (i64)invFact[m] % P * invFact[n - m] % P;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
inv[1] = fact[0] = fact[1] = invFact[0] = invFact[1] = 1;
for(int i = 2; i < N; i ++) {
inv[i] = (P - P / i) * (i64)inv[P % i] % P;
fact[i] = fact[i - 1] * (i64)i % P;
invFact[i] = invFact[i - 1] * (i64)inv[i] % P;
}
int n;
cin >> n;
int a = 0, b = 0, c = 0;
for(int i = 1, x; i <= n; i ++) {
cin >> x;
if(x < 0) a ++;
if(x > 0) b ++;
if(x == 0) c ++;
}
int ans = 1;
if(a > 0) ans = ans * (i64)qpow(2, a - 1) % P;
if(b > 0) ans = ans * (i64)qpow(2, b - 1) % P;
if(a > 0 && b > 0) (ans *= 2) %= P;
if(c) ans = ans * (1ll + (a > 0) + (b > 0)) % P;
cout << ans << "\n";
}
鴨志田卓