2 条题解
-
0
#include <bits/stdc++.h> using namespace std; #define int long long const int mod = 998244353; const int maxn = 1e5 + 5; int n, x[maxn], y[maxn], p[maxn]; int fpow(int a, int b) { int ans = 1, t = a; while (b) { if (b & 1) ans = ans * t % mod; t = t * t % mod; b >>= 1; } return ans; } int inv(int a) { return fpow(a, mod-2); } signed main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i]; p[i] = x[i] * inv(y[i]) % mod; } int x = 0, y = 0; for (int i = 1, t = 1; i <= n; i++) { x += t * p[i] % mod; x %= mod; y += t; y %= mod; t = t * (1 - p[i] + mod) % mod; } cout << y * inv((1 - x + mod) % mod) % mod << endl; return 0; } -
0
- 1
信息
- ID
- 45
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- (无)
- 递交数
- 10
- 已通过
- 4
- 上传者