Codeforces Round #439 (Div. 2)
来源:互联网 发布:les聊天软件 编辑:程序博客网 时间:2024/06/05 11:24
Codeforces Round #439 (Div. 2)
A. The Artful Expedient
由于
Karen
B. The Eternal Immortality
差超过5的一定是0,否则暴力就好。
#include <bits/stdc++.h>using namespace std;long long a, b;int main(){ cin >> a >> b; if (b-a > 20) puts("0"); else { long long ans = 1; for (long long i = b; i > a; i--) ans = ans*(i%10)%10; cout << ans << endl; } return 0;}
C. The Intriguing Obsession
三种颜色的岛屿分别有
显然这个要求等价于不能有一个节点连向两个同色节点。考虑分别由
暴力计算即可。
#include <bits/stdc++.h>using namespace std;const int MAXN = 5005, mod = 998244353;int C[MAXN][MAXN], fac[MAXN];int a, b, c;int main(){ scanf("%d%d%d", &a, &b, &c); C[0][0] = 1; for (int i = 1; i <= 5000; i++) for (int j = 0; j <= i; j++) C[i][j] = (C[i-1][j]+C[i-1][j-1]*(j!=0))%mod; fac[0] = 1; for (int i = 1; i <= 5000; i++) fac[i] = (long long)fac[i-1]*i%mod; int ans[3] = {0, 0, 0}; for (int i = 0; i <= a; i++) ans[0] = (ans[0]+(long long)C[a][i]*C[b][i]%mod*fac[i]%mod)%mod; for (int i = 0; i <= a; i++) ans[1] = (ans[1]+(long long)C[a][i]*C[c][i]%mod*fac[i]%mod)%mod; for (int i = 0; i <= c; i++) ans[2] = (ans[2]+(long long)C[c][i]*C[b][i]%mod*fac[i]%mod)%mod; cout << (long long)ans[0]*ans[1]%mod*ans[2]%mod << endl; return 0;}
E. The Untended Antiquity(补)
题意:一个
- 在一个矩形外安栅栏
- 拆掉一个安过的栅栏
- 询问两点是否联通
没见过的套路orz,就是给每个栅栏随机一个权值,然后用二维树状数组大力维护一下,每次安栅栏就给矩形内的点异或一个权值。如果两点权值相等则两点联通。
#include <bits/stdc++.h>using namespace std;const int MAXN = 2505;typedef unsigned long long ull;ull c[MAXN][MAXN];int n, m, q;inline int lowbit(int nd){ return nd&(-nd); }struct pt { int x1, y1, x2, y2; friend bool operator < (const pt &a, const pt &b) { if (a.x1 != b.x1) return a.x1 < b.x1; if (a.y1 != b.y1) return a.y1 < b.y1; if (a.x2 != b.x2) return a.x2 < b.x2; return a.y2 < b.y2; }};map<pt, ull> dt;void modify(int x, int y, ull dt){ for (int i = x; i <= n; i += lowbit(i)) for (int j = y; j <= m; j += lowbit(j)) c[i][j] ^= dt;}ull sum(int x, int y){ ull ans = 0; for (int i = x; i; i -= lowbit(i)) for (int j = y; j; j -= lowbit(j)) ans ^= c[i][j]; return ans;}void cover(int x1, int y1, int x2, int y2, ull dt){ modify(x1, y1, dt); modify(x1, y2+1, dt); modify(x2+1, y1, dt); modify(x2+1, y2+1, dt);}int main(){ srand(time(0)); scanf("%d%d%d", &n, &m, &q); for (int i = 1; i <= q; i++) { int t, r1, r2, c1, c2; scanf("%d%d%d%d%d", &t, &r1, &c1, &r2, &c2); if (t == 1) { ull rk = rand()*RAND_MAX+rand(); // cerr << rk << endl; dt[(pt){r1, c1, r2, c2}] = rk; cover(r1, c1, r2, c2, rk); } else if (t == 2) { ull rk = dt[(pt){r1, c1, r2, c2}]; cover(r1, c1, r2, c2, rk); } else { if (sum(r1, c1) == sum(r2, c2)) puts("Yes"); else puts("No"); } } return 0;}
阅读全文
0 0
- Codeforces Round #439 (Div. 2)
- Codeforces Round #439 (Div. 2)
- Codeforces Round #439 (Div.2)
- Codeforces Round #439 (Div.2)
- Codeforces Round #439 (Div. 2)
- Codeforces Round #439 (Div. 2)
- Codeforces Round #439 (Div. 2)
- Codeforces Round #439 (Div. 2) C
- Codeforces Round #439 (Div. 2) 题解
- Codeforces Round #439 (Div. 2) 总结
- Codeforces Round #439 (Div. 2)A,B
- Codeforces Round #439 (Div. 2)E详解
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- c++回文日期【NOIP2016普及组】解题报告
- JQuery
- 电影样题的数据清洗
- struts2的简单使用
- CSS3圆角
- Codeforces Round #439 (Div. 2)
- 线程同步之互斥锁(互斥量)
- 第四周项目 third---单链表应用
- 树的直径
- Mybatis中模糊查询的各种写法
- 【面向HTML--其它标签】
- php绘制柱形图
- 关于二维码和动态权限申请的一些功能实现
- 小东西