cf618 训练cde
Posted zsben991126
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cf618 训练cde相关的知识,希望对你有一定的参考价值。
面完试第一场vp cf,感觉题目挺规矩的,可能是有些历史了
c
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; const int N = 1e5 + 10; int sum[N]; int main() { int n; scanf("%d", &n); vector<int> a(n); int ma = 0; for (auto& i : a) { scanf("%d", &i); int cnt = 0, t = i; while (t) { if (t & 1) { ++sum[cnt]; } t >>= 1; cnt++; } ma = max(ma, cnt); } int ans = inf; for (int i = ma - 1; i >= 0; i--) { if (sum[i] == 1) { ans = i; break; } } if (ans != inf) { int tp = 0; for (int i = 0; i < n; i++) { if (a[i] & (1 << ans)) { tp = i; break; } } printf("%d", a[tp]); for (int i = 0; i < n; i++) { if (i != tp) { printf(" %d", a[i]); } } printf(" "); } else { for (int i = 0; i < n; i++) { printf("%d", a[i]); if (i != n - 1) printf(" "); else printf(" "); } } return 0; }
d,有点几何的感觉
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e5 + 10; const double eps = 1e-9; struct point { int x, y; point operator - (const point& b) { return { x - b.x, y - b.y }; } bool operator == (const point& b) { return x == b.x && y == b.y; } }; bool ki(point a, point b, point c, point d) { return (b - a) == (c - d); } int main() { int n; scanf("%d", &n); vector<point> q(n); for (auto& v : q) { scanf("%d%d", &v.x, &v.y); } if (n & 1) { printf("NO "); } else { bool can = true; for (int i = 0; can && i < n / 2; i++) { if (!ki(q[i], q[i + 1], q[i + n / 2], q[(i + n / 2 + 1) % n])) { can = false; } } if (can)printf("YES "); else printf("NO "); } return 0; }
e,也是几何。。
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e5 + 10; const double eps = 1e-9; struct point { int x, y; point operator - (const point& b) { return { x - b.x, y - b.y }; } bool operator == (const point& b) { return x == b.x && y == b.y; } }; bool ki(point a, point b, point c, point d) { return (b - a) == (c - d); } int main() { int n; scanf("%d", &n); vector<point> q(n); for (auto& v : q) { scanf("%d%d", &v.x, &v.y); } if (n & 1) { printf("NO "); } else { bool can = true; for (int i = 0; can && i < n / 2; i++) { if (!ki(q[i], q[i + 1], q[i + n / 2], q[(i + n / 2 + 1) % n])) { can = false; } } if (can)printf("YES "); else printf("NO "); } return 0; }
以上是关于cf618 训练cde的主要内容,如果未能解决你的问题,请参考以下文章