• 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;
    }
    View Code
  • 相关阅读:
    nginx限速 原理
    规则引擎 图形界面
    阿里巴巴 规则引擎
    martinfowler Data Guide big data bad things
    Nginx Request URI too large
    linux2.6.30.4内核移植(1)
    根文件系统
    Linux内核配置:定制配置选项
    Linux内核配置:Kconfig
    Linux内核配置:Makefile目标
  • 原文地址:https://www.cnblogs.com/zsben991126/p/13193260.html
Copyright © 2020-2023  润新知