QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#395251 | #3083. Bit Operation | SamponYW | WA | 53ms | 11852kb | C++14 | 1.7kb | 2024-04-21 11:41:40 | 2024-04-21 11:41:41 |
Judging History
answer
#include <bits/stdc++.h>
#define db double
#define il inline
#define re register
#define ll long long
#define ui unsigned
#define ull ui ll
#define i128 __int128
#define pii pair<int, int>
#define fi first
#define se second
#define eb emplace_back
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define mems(v, x) memset(v, x, sizeof(v))
#define memc(a, b) memcpy(a, b, sizeof(a))
#define FOR(i, L, R) for(re int i = (L); i <= (R); ++i)
#define ROF(i, R, L) for(re int i = (R); i >= (L); --i)
#define LS i << 1, l, mid
#define RS i << 1 | 1, mid + 1, r
#define popc(x) __builtin_popcount(x)
using namespace std;
using poly = vector<int> ;
using Fp = pair<poly, poly> ;
#define N (1 << 19)
#define P 998244353
il int add(int x, int y) {return x + y < P ? x + y : x + y - P;}
il void addr(int &x, int y) {(x += y) >= P && (x -= P);}
il int qpow(int p, int n = P - 2) {
int s = 1;
while(n) {
if(n & 1) s = 1ll * s * p % P;
p = 1ll * p * p % P, n >>= 1;
}
return s;
}
int n, a[N], dp[N];
int fac[N], ifac[N];
il int C(int n, int m) {return n < m ? 0 : 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n, dp[0] = 1;
FOR(i, 1, n) dp[i] = add(dp[i - 1], 2ll * (i - 1) * dp[i - 1] % P);
fac[0] = 1; FOR(i, 1, n) fac[i] = 1ll * fac[i - 1] * i % P;
ifac[n] = qpow(fac[n]); ROF(i, n - 1, 0) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % P;
int ans = 0;
FOR(i, 1, n) {
int x; cin >> x;
if(x) addr(ans, 1ll * dp[i - 1] * dp[n - i] % P * C(n - 1, i - 1) % P);
}
cout << ans;
cerr << 1.0 * clock() / CLOCKS_PER_SEC;
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 53ms
memory: 11852kb
input:
999993 1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 1 1 1 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0 1 1 0 1 0 0 0 0 1 1 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 1...
output:
837453178
result:
wrong answer 1st lines differ - expected: '318158140', found: '837453178'