• AtCoderBeginnerContest109题解


    第一次AK,真爽qwq

    A

    很zz啊,,直接判断三种情况就行

    /*
     
    */
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<map>
    #include<vector>
    #include<set>
    #include<queue>
    #include<cmath>
    //#include<ext/pb_ds/assoc_container.hpp>
    //#include<ext/pb_ds/hash_policy.hpp>
    #define Pair pair<int, int>
    #define MP(x, y) make_pair(x, y)
    #define fi first
    #define se second
    #define int long long 
    #define LL long long 
    #define ull unsigned long long 
    #define rg register 
    #define pt(x) printf("%d ", x);
    //#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
    //char buf[(1 << 22)], *p1 = buf, *p2 = buf;
    //char obuf[1<<24], *O = obuf;
    //void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
    //#define OS  *O++ = ' ';
    using namespace std;
    //using namespace __gnu_pbds;
    const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
    const double eps = 1e-9;
    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 check(int a, int b, int c) {
        return a * b * c & 1;
    }
    main() {
        int A = read(), B = read();
        if(check(1, A, B) || check(2, A, B) || check(3, A, B)) puts("Yes");
        else puts("No");
     
     
     
     
        return 0;
    }
    /*
    2 2 1
    1 1
    2 1 1
    */
    A

    B

    直接模拟即可

    /*
     
    */
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<map>
    #include<vector>
    #include<set>
    #include<queue>
    #include<cmath>
    //#include<ext/pb_ds/assoc_container.hpp>
    //#include<ext/pb_ds/hash_policy.hpp>
    #define Pair pair<int, int>
    #define MP(x, y) make_pair(x, y)
    #define fi first
    #define se second
    #define int long long 
    #define LL long long 
    #define ull unsigned long long 
    #define rg register 
    #define pt(x) printf("%d ", x);
    //#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
    //char buf[(1 << 22)], *p1 = buf, *p2 = buf;
    //char obuf[1<<24], *O = obuf;
    //void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
    //#define OS  *O++ = ' ';
    using namespace std;
    //using namespace __gnu_pbds;
    const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
    const double eps = 1e-9;
    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;
    }
    map<string, bool> mp;
    int N;
    string s[MAXN];
    main() {
        int N = read();
        
        for(int i = 1; i <= N; i++) {
            cin >> s[i];
            if(mp.find(s[i]) != mp.end()) {puts("No"); return 0;}
            if(i > 1) {
                int l = s[i - 1].length();
                if(s[i][0] != s[i - 1][l - 1]) {puts("No"); return 0;
                }
            }
            mp[s[i]] = 1;
        }
        puts("Yes");
     
        return 0;
    }
    /*
    2 2 1
    1 1
    2 1 1
    */
    B

    C

    一开始想二分来着,然后发现我zz了。

    直接输出 所有距离与起始距离的最大公约数即可

    证明显然。。。

    /*
     
    */
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<map>
    #include<vector>
    #include<set>
    #include<queue>
    #include<cmath>
    //#include<ext/pb_ds/assoc_container.hpp>
    //#include<ext/pb_ds/hash_policy.hpp>
    #define Pair pair<int, int>
    #define MP(x, y) make_pair(x, y)
    #define fi first
    #define se second
    #define int long long 
    #define LL long long 
    #define ull unsigned long long 
    #define rg register 
    #define pt(x) printf("%d ", x);
    //#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
    //char buf[(1 << 22)], *p1 = buf, *p2 = buf;
    //char obuf[1<<24], *O = obuf;
    //void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
    //#define OS  *O++ = ' ';
    using namespace std;
    //using namespace __gnu_pbds;
    const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
    const double eps = 1e-9;
    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, a[MAXN];
    main() {
        int N = read(), X = read();
        for(int i = 1; i <= N; i++) a[i] = read();
        int g = abs(X - a[1]);
        for(int i = 2; i <= N; i++) {
            int dis = abs(X - a[i]);
            g = __gcd(g, dis);
        }
        printf("%d", g);
        return 0;
    }
    /*
    2 2 1
    1 1
    2 1 1
    */
    C

    D

    一开始读错题了,我以为移动几个都可以,事实上只能移动一个qwq,而且我以为0不统计入答案

    我还特地问了一下,真没想到他居然知道我问的什么

    考虑一个很显然的正确做法。。

    先把所有奇数点往下移动,直到移动到最后一行

    再把最后一行的奇数点从左往右移动。。

    /*
     
    */
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<map>
    #include<vector>
    #include<set>
    #include<queue>
    #include<cmath>
    //#include<ext/pb_ds/assoc_container.hpp>
    //#include<ext/pb_ds/hash_policy.hpp>
    #define Pair pair<int, int>
    #define MP(x, y) make_pair(x, y)
    #define fi first
    #define se second
    //#define int long long 
    #define LL long long 
    #define ull unsigned long long 
    #define rg register 
    #define pt(x) printf("%d ", x);
    //#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
    //char buf[(1 << 22)], *p1 = buf, *p2 = buf;
    //char obuf[1<<24], *O = obuf;
    //void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
    //#define OS  *O++ = ' ';
    using namespace std;
    //using namespace __gnu_pbds;
    const int MAXN = 501, INF = 1e9 + 10, mod = 1e9 + 7;
    const double eps = 1e-9;
    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;
    int a[MAXN][MAXN];
    int xx[6] = {0, -1, +1, 0, 0};
    int yy[6] = {0, 0, 0, -1, +1};
    int ans[MAXN * MAXN][7], cnt = 0;
    void add(int i, int j, int wx, int wy) {
        ans[++cnt][0] = i;
        ans[cnt][1] = j;
        ans[cnt][2] = wx;
        ans[cnt][3] = wy;    
    }
    main() {
        N = read(); M = read();
        for(int i = 1; i <= N; i++)
            for(int j = 1; j <= M; j++)
                a[i][j] = read();
        for(int i = 1; i < N; i++) {
            for(int j = 1; j <= M; j++) {
                if(a[i][j] & 1) {
                    int wx = i + 1, wy = j;
                    a[i][j]--; a[wx][wy]++;
                    add(i, j, wx, wy);
                }
            }
        }
        for(int i = 1; i < M; i++) {
            if(a[N][i] & 1) {
                a[N][i]--; a[N][i + 1]++;
                add(N, i, N, i + 1);
            }
        }
        printf("%d
    ", cnt);
        for(int i = 1; i <= cnt; i++) 
            printf("%d %d %d %d
    ", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
        return 0;
    }
    /*
    2 2 1
    1 1
    2 1 1
    */
    D
  • 相关阅读:
    delphi算法
    delphi 弹出选择目录窗口
    delphi 导出xml文件
    play 源码分析
    oracle指令
    delphi 环境问题
    如何启动redis
    关于整理和工作小结
    如何强制关闭服务
    delphi之事件
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/9614663.html
Copyright © 2020-2023  润新知