• 牛客OI周赛9-普及组


    https://ac.nowcoder.com/acm/contest/696#question

    A

    代码:

    #include <bits/stdc++.h>
    using namespace std;
     
    int T;
    char c[10] = {'N', 'o', 'w', 'C', 'o', 'd', 'e', 'r'};
     
    bool f(string s) {
        int len = s.length();
        int pos = 0;
        for(int i = 0; i < len; i ++) {
            if(s[i] == c[pos]) pos ++;
        }
        if(pos == 8) return true;
        return false;
    }
     
    int main() {
        scanf("%d", &T);
        while(T --) {
            string s;
            cin >> s;
            if(f(s)) printf("QAK
    ");
            else printf("QIE
    ");
        }
        return 0;
    }
    View Code

    B

    代码:

    #include <bits/stdc++.h>
    using namespace std;
     
    const int maxn = 1e5 + 10;
    int N;
    long long a[maxn];
     
    int getlen(long long x) {
        int cnt = 0;
        if(x == 0) return 1;
        while(x) {
            cnt ++;
            x /= 2;
        }
        return cnt;
    }
     
    int BitCount2(long long n) {
        int c = 0;
        for(c =0; n; ++ c)
            n &= (n - 1);
        return c ;
    }
     
    int sum(long long x) {
        int a = getlen(x);
        int b = BitCount2(x);
     
        if(b * 2 > a) return 1;
        return -1;
    }
     
    int main() {
        scanf("%d", &N);
        long long ans = 0;
        for(int i = 0; i < N; i ++) {
            scanf("%lld", &a[i]);
            a[i] = abs(a[i]);
            ans += sum(a[i]);
        }
        printf("%lld
    ", ans);
        return 0;
    }
    View Code

    C

    代码:

    #include <bits/stdc++.h>
    using namespace std;
     
    int mod = 1e9 + 7;
    int N;
     
    long long Pow(long long a, long long b) {
        long long ans1 = 1;
     
        a = a % mod;
     
        while(b) {
            if(b % 2) {
                ans1 = (ans1 * a) % mod;
                b --;
            } else {
                a = (a * a) % mod;
                b /= 2;
            }
        }
        return ans1;
    }
     
    int main() {
        scanf("%d", &N);
        long long ans = 0;
        if(N < 3)
            ans = Pow(26, N);
        else ans = 3 * Pow(25, N) - 3 * Pow(24, N) + Pow(23, N);
        ans = (ans % mod + mod) % mod;
        printf("%lld
    ", ans % mod);
        return 0;
    }
    View Code

     

  • 相关阅读:
    python实现满二叉树递归循环
    二叉树遍历规则,先顺遍历/中序遍历/后序遍历
    满二叉树的循环递归
    python 中的super()继承,搜索广度为先
    UITableview 中获取非选中的cell
    iOS——UIButton响应传参数
    iOS- iPad UIPopoverController
    IPAD之分割视图 SplitViewController
    IOS7 隐藏状态栏
    iOS 强制横屏
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/10815289.html
Copyright © 2020-2023  润新知