zoukankan      html  css  js  c++  java
  • AtCoder Beginner Contest 103

    刚刚天真的跑去打codechef,才发现那是IOI模拟赛qwq。

    atc是比赛还剩40min结束的时候才打的,就做了前三个题

    T1

    zz模拟

    #include<cstdio>
    #include<algorithm>
    using namespace std;
    const int MAXN = 1e5 + 10, INF = 1e9;
    inline int read() {
        char c = getchar(); int x = 0, f = 1;
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    int a[5];
    int main() {
        a[1] = read(); a[2] = read(); a[3] = read();
        sort(a + 1, a + 4);
        printf("%d", abs(a[2] - a[1]) + abs(a[3] - a[2]));
        return 0;
    }
    T1

    T2

    zz模拟

    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<iostream>
    using namespace std;
    const int MAXN = 1e5 + 10, INF = 1e9;
    inline int read() {
        char c = getchar(); int x = 0, f = 1;
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    string a, b;
    int main() {
        cin >> a >> b;
        int N = a.length();
        if(N != b.length()) {puts("No"); return 0;}
        //for(int i = 0; i < N; i++) a[i + N] = a[i];
        a = a + a;
        //cout << a << endl << b;
        if(a.find(b) != string::npos) puts("Yes");
        else puts("No");
        return 0;
    }
    T2

    T3

    这个就比较厉害了。

    首先我们发现,对于每个$a_i$,我们都可以构造一个数使得$x pmod {a_i} = a_i - 1$

    那么输出$sum_{i = 1}^n a_i - 1$就行了

    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<iostream>
    //#define int long long 
    using namespace std;
    const int MAXN = 1e5 + 10, INF = 1e9;
    inline int read() {
        char c = getchar(); int x = 0, f = 1;
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    int N;
    int a[MAXN], sum = 0;
    int check(int val) {
        int ret = 0;
        for(int i = 1; i <= N; i++)
            ret += val % a[i];
        return ret;
    }
    main() {
        N = read();
        for(int i = 1; i <= N; i++) 
            a[i] = read(), sum += a[i] - 1;
        printf("%d", sum); 
        return 0;
    }
    T3

    T4

    首先按照套路按照右端点排序

    然后按照从左到右的顺序依次在右端点切就行了

    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<iostream>
    #define MP(x, y) make_pair(x, y)
    #define Pair pair<int, int> 
    //#define int long long 
    using namespace std;
    const int MAXN = 1e6 + 10, INF = 1e9;
    inline int read() {
        char c = getchar(); int x = 0, f = 1;
        while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
        while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x * f;
    }
    int N, M;
    Pair P[MAXN];
    main() {
        N = read(); M = read();
        for(int i = 1; i <= M; i++) {
            int x = read(), y = read();
            P[i] = MP(y, x);
        }
        int ans = 0, last = -1;
        sort(P + 1, P + M + 1);
        for(int i = 1; i <= M;) {
            int j = i + 1;
            while(j <= M && P[i].first == P[j].first) j++;
            if(P[j - 1].second >= last) 
                ans++,          = P[j - 1].first;
            i = j;
        }
        printf("%d
    ", ans);
        return 0;
    }
    T4
  • 相关阅读:
    七十九:flask.Restful之flask-Restful蓝图与渲染模板
    七十九:flask.Restful之flask-Restful标准化返回参数示例
    七十八:flask.Restful之flask-Restful标准化返回参数以及准备数据
    七十七:flask.Restful之flask-Restful参数验证
    七十六:flask.Restful之flask-Restful插件的基本使用
    七十五:flask.Restful之Restful.API介绍
    七十四:flask信号之flask的内置信号
    七十三:flask信号之信号机制和使用场景
    七十二:flask钩子函数之关于errorhandler的钩子函数
    七十一:flask钩子函数之关于context_processor的钩子函数
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/9348500.html
Copyright © 2011-2022 走看看