AtCoder Grand Contest 019 F
来源:互联网 发布:淘宝10元跳蛋靠谱吗 编辑:程序博客网 时间:2024/06/07 01:05
链接:
link
题意:
有
题解:
显然最优策略是回答多的那个。
不妨设
画一条对角线
我们考虑计算答案的增量,发现在对角线处才会贡献有
代码:
#include <bits/stdc++.h>#define xx first#define yy second#define mp make_pair#define pb push_back#define mset(x, y) memset(x, y, sizeof x)#define mcpy(x, y) memcpy(x, y, sizeof x)using namespace std;typedef long long LL;typedef pair <int, int> pii;inline int Read(){ int x = 0, f = 1, c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return x * f;}const int MAXN = 1000005;const int mod = 998244353;int n, m, ans, sum, fac[MAXN], inv[MAXN];inline int C(int n, int m){ return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;}int main(){#ifdef wxh010910 freopen("data.in", "r", stdin);#endif n = Read(), m = Read(); if (n < m) swap(n, m); ans = n; fac[0] = fac[1] = inv[0] = inv[1] = 1; for (int i = 2; i <= n + m; i ++) fac[i] = 1LL * fac[i - 1] * i % mod, inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod; for (int i = 2; i <= n + m; i ++) inv[i] = 1LL * inv[i] * inv[i - 1] % mod; for (int i = 1; i <= m; i ++) sum = (1LL * C(i << 1, i) * C(n + m - (i << 1), n - i) + sum) % mod; return printf("%d\n", (1LL * sum * inv[2] % mod * inv[n + m] % mod * fac[n] % mod * fac[m] + ans) % mod), 0;}
阅读全文
0 0
- AtCoder Grand Contest 019 F
- Atcoder Grand Contest 011F
- Atcoder Grand Contest 014F
- Atcoder Grand Contest 016F
- AtCoder Grand Contest 018 F
- AtCoder Grand Contest 010 F
- Atcoder Grand Contest 019
- AtCoder Grand Contest 001 F permutation
- AtCoder Grand Contest 019 B
- Atcoder Grand Contest 019 总结
- AtCoder Grand Contest 019 C
- AtCoder Grand Contest 019 E
- (AtCoder Grand Contest 019) C
- 【AtCoder Grand Contest 001 F】【JZOJ 5405】 Permutation
- AtCoder Grand Contest 010
- AtCoder Grand Contest 011
- AtCoder Grand Contest 018
- AtCoder Grand Contest 018
- HDU2582(素数筛)
- 倒置函数reverse的用法
- Java的Stirng.split方法注意点
- 2 汽车销售行业行为识别
- DOM之鼠标事件
- AtCoder Grand Contest 019 F
- SO_REUSEADDR和SO_REUSEPORT异同
- Redhat 6.5 配置kdump方法
- webpack前端工具
- 【年终总结】——梦想起航
- SQL万能密码:' or 1='1
- javascript的垃圾回收机制与内存管理
- LightOJ
- Java IO与NIO