标签:图片 历史 display 技术 div inf turn auto str
面完试第一场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("\n"); } else { for (int i = 0; i < n; i++) { printf("%d", a[i]); if (i != n - 1) printf(" "); else printf("\n"); } } 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\n"); } 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\n"); else printf("NO\n"); } 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\n"); } 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\n"); else printf("NO\n"); } return 0; }
标签:图片 历史 display 技术 div inf turn auto str
原文地址:https://www.cnblogs.com/zsben991126/p/13193260.html