zoukankan      html  css  js  c++  java
  • Codeforces Round #473 (Div. 2)

    这场怎么都是异或啊qwq。。。

    A. Mahmoud and Ehab and the even-odd game

    直接判断奇偶性

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define int long long 
    using namespace std;
    const int MAXN = 2 * 1e6 + 10, INF = 1e9 + 10, B = 63;
    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;
    }
    main() { 
    #ifdef WIN32
        //freopen("a.in", "r", stdin);
    #endif
        int N = read();
        puts(N & 1 ? "Ehab" : "Mahmoud");
    }
    A

    B. Mahmoud and Ehab and the message

    维护出每个graph的最小值,输出即可,我咋还开了个map

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    #include<map>
    #define int long long 
    using namespace std;
    const int MAXN = 2 * 1e6 + 10, INF = 1e9 + 10, B = 63;
    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, G, M;
    string s[MAXN];
    int val[MAXN], minval[MAXN];
    map<string, int> ID;
    main() { 
    #ifdef WIN32
        //freopen("a.in", "r", stdin);
    #endif
        memset(minval, 0x3f, sizeof(minval));
        N = read(); G = read(); M = read();
        for(int i = 1; i <= N; i++) 
            cin >> s[i];
            //cout << s << endl;
        for(int i = 1; i <= N; i++) 
            val[i] = read();
        for(int i = 1; i <= G; i++) {
            int num = read();
            for(int j = 1; j <= num; j++) {
                int x = read();
                ID[s[x]] = i;
            }
        }
        
        for(int i = 1; i <= N; i++)
            minval[ID[s[i]]] = min(minval[ID[s[i]]], val[i]);
        //for(int i = 1; i <= N; i++) printf("%d ", ID[s[i]]); puts("***");
        //for(int i = 1; i <= N; i++) printf("%d ", minval[ID[s[i]]]); puts("***");
        int ans = 0;
        string x;
        for(int i = 1; i <= M; i++) {
            cin >> x;
            ans += minval[ID[x]];
        }
        printf("%I64d", ans);
    }
    B

    C. Mahmoud and Ehab and the wrong algorithm

    我的构造思路比较奇葩,大概长这样。。

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    #include<map>
    using namespace std;
    const int MAXN = 2 * 1e6 + 10, INF = 1e9 + 10, B = 63;
    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;
    }
    
    main() { 
    #ifdef WIN32
        //freopen("a.in", "r", stdin);
    #endif
        int N = read();
        if(N == 2 || N == 3 || N == 4 || N == 5) printf("-1
    ");
        else {
            printf("1 2
    ");
            printf("1 3
    ");
            printf("1 4
    ");
            for(int i = 5; i <= N; i++) 
                printf("3 %d
    ", i);
        }
        for(int i = 1; i <= N - 1; i++) 
            printf("%d %d
    ", i, i + 1);
    }
    C

     

    E. Mahmoud and Ehab and the xor-MST

    打表后强上oeis

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    #include<map>
    #define int long long 
    using namespace std;
    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<int, int> ans;
    int B(int x) {
        if(ans[x] ) return ans[x];
        if(x & 1) return ans[x] = 2 * B(x / 2) + (x / 2) + 1;
        else return ans[x] = 2 * B(x / 2) + x / 2;
    }
    main() { 
    #ifdef WIN32
        //freopen("a.in", "r", stdin);
    #endif
        ans[1] = 1;
        int N = read();
        printf("%I64d", B(N - 1));
    }
    E
  • 相关阅读:
    Linux配置SSH公钥认证与Jenkins远程登录进行自动发布
    在阳台上种花生
    已知传递函数,求幅频响应?
    win8快速锁屏
    word2016怎么让目录索引显示在左边?
    Matlab 瑞利信道仿真
    rayleighchan实现瑞利多径衰落信
    2017电商趋势
    【连载7】二手电商平台的账号与信用体系
    【连载6】二手电商APP的导购功能与关系链机制分析
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/9190667.html
Copyright © 2011-2022 走看看