Codeforces Round #266 (Div. 2)_html/css_WEB-ITnose

Codeforces Round #266 (Div. 2)

题目链接

A:就简单的判断一下那种更大即可

B:枚举x到sqrt(n),然后可以直接算出y,然后判断一下即可

C:先判断和是否是3的倍数,然后预处理出前缀和出现位置和后缀和对应sum / 3个数,然后从头往后扫一遍把当前一个和后面进行组合即可

D:先预处理出差分,使得数组表示线段的添加方式,然后每次有一个-1,就能和前面多少个1进行匹配,方案数就乘上多少,如果是0,就能和前面+1个匹配

立即学习“前端免费学习笔记(深入)”;

E:利用并查集,把每次询问拆分成2个部分,起点到x,x到根,然后每次从根往下dfs一遍,对应询问符合的就把对应询问++,dfs完如果一个询问符合两次,就是符合的输出YES,否则就是NO

代码:

#include #include int n, m, a, b;int solve() {if (b >= m * a) return a * n;int yu = n % m;int ans = n / m * b;if (yu * a   
B:

#include #include #include #include using namespace std;typedef long long ll;ll n, a, b;int main() {scanf("%lld%lld%lld", &n, &a, &b);n = n * 6;ll ans = 1e18, x, y;if (a * b >= n) {x = a;y = b;ans = a * b;}else {int flag = 0;if (a > b) {flag = 1;swap(a, b);}for (int i = 1; i  r) swap(l, r);if (l   
C:

#include #include const int N = 500005;typedef long long ll;int n;ll a[N], pres[N], prec[N], sufs[N], sufc[N];int main() {scanf("%d", &n);ll sum = 0;for (int i = 1; i = 1; i--) {sufs[i] = sufs[i + 1] + a[i];sufc[i] = sufc[i + 1];if (sufs[i] == sum) sufc[i]++;}ll ans = 0;for (int i = 1; i   
D:

#include #include typedef long long ll;const int MOD = 1000000007;const int N = 2005;int n, h, a[N], b[N];int main() {scanf("%d%d", &n, &h);for (int i = 1; i   
E:

#include #include #include #include using namespace std;#define MP(a,b) make_pair(a,b)typedef pair pii;const int N = 100005;int n, m, parent[N];int find(int x) {return x == parent[x] ? x : parent[x]  = find(parent[x]);}vector p, q[N];vector g[N];int tot, vis[N], cnt[N];void dfs(int u) {vis[u] = 1;for (int i = 0; i   

登录后复制

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2839706.html

(0)
上一篇 2025年3月9日 14:01:29
下一篇 2025年3月9日 14:01:37

AD推荐 黄金广告位招租... 更多推荐

相关推荐

发表回复

登录后才能评论