zoukankan      html  css  js  c++  java
  • 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛

    跳台阶

    #include<algorithm>
    #include<iostream>
    #include<vector>
     
     
    using namespace std;
     
    int main(){
        int T, n;
        cin >> T;
        while(T--){
            cin >> n;
            cout << (int)pow(2, n - 1) << endl;
        }
    }

    psd面试

    #include<algorithm>
    #include<iostream>
    #include<vector>
    #include<cctype>
    #include<cstdio>
    #include<cstring>
    #include<map>
     
    using namespace std;
    const int N = 1234 + 5;
    int  f[N][N];
    int LPS_Length(string s,int len){
        for (int i=len-1;i>=0;i--){
            f[i][i]=1;
            for (int j=i+1;j<len;j++){
                if (s[i]==s[j])
                    f[i][j]=f[i+1][j-1]+2;
                else
                    f[i][j]=max(f[i][j-1],f[i+1][j]);
            }
        }
        return f[0][len-1];
    }
    int main(){
        string str;
        while(cin >> str){
            for(auto &c: str) c = toupper(c);
            cout << str.length() - LPS_Length(str, int(str.length())) << endl;
        }
    }

    回旋星空

    #include<algorithm>
    #include<iostream>
    #include<vector>
    #include<cstdio>
    #include<cstring>
    #include<map>
     
    using namespace std;
    const int N = 1000 + 5;
    struct point{
        double x, y;
    }p[N];
    int n;
    void Work(){
     
    }
     
    double dist(point &p1, point &p2){
        return sqrt((p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y));
    }
    int main(){
        int T;
        scanf("%d", &T);
        while(T --){
            scanf("%d", &n);
            for(int i = 0; i < n; i++)
                scanf("%lf%lf",&p[i].x,&p[i].y);
            int cnt  = 0;
            for(int i = 0; i < n; i++){
                map<double, int> mat;
                for(int j = 0; j < n; j++){
                        if(i == j) continue;
                        double dis = dist(p[i], p[j]);
                        cnt += mat[dis];
                        mat[dis]++;
                }
            }
            if(cnt == 0)
                printf("WA
    ");
            else
                printf("%d
    ", cnt * 2);
        }
    }

    旋转矩阵

    #include<algorithm>
    #include<iostream>
    #include<vector>
    #include<cstdio>
    #include<cstring>
     
    using namespace std;
    const int N = 50 + 5;
     
    int n, m;
    char mat[N][N], op[1000 + 5];
     
     
    void Work(){
        int len = strlen(op);
        int cnt = 0;
        for(int i = 0; i < len; i++)
            if(op[i] == 'L') cnt = (cnt + 1) % 4;
            else cnt = (cnt - 1 + 4) % 4;
     
        if(cnt == 0){
            printf("%d %d
    ", n, m);
            for(int i = 0; i < n; i++){
     
                for(int j = 0; j < m; j++){
                    if(mat[i][j] == '-'){
                        if(len & 1) printf("|");
                        else printf("-");
                    }else if(mat[i][j] == '|'){
                        if(len & 1) printf("-");
                        else printf("|");
                    }else printf("+");
                }printf("
    ");
            }
        }else if(cnt == 1){
            printf("%d %d
    ", m, n);
            for(int i =  m - 1; i >= 0; i--){
     
                for(int j = 0; j < n; j++){
                    if(mat[j][i] == '-'){
                        if(len & 1) printf("|");
                        else printf("-");
                    }else if(mat[j][i] == '|'){
                        if(len & 1) printf("-");
                        else printf("|");
                    }else printf("+");
                }printf("
    ");
            }
        }else if(cnt == 2){
            printf("%d %d
    ", n, m);
            for(int i =  n - 1; i >= 0; i--){
     
                for(int j = m - 1; j >= 0; j--){
                    if(mat[i][j] == '-'){
                        if(len & 1) printf("|");
                        else printf("-");
                    }else if(mat[i][j] == '|'){
                        if(len & 1) printf("-");
                        else printf("|");
                    }else printf("+");
                }printf("
    ");
            }
        }else{
            printf("%d %d
    ", m, n);
            for(int i = 0; i < m; i++){
     
                for(int j = n-1; j >= 0; j--){
                    if(mat[j][i] == '-'){
                        if(len & 1) printf("|");
                        else printf("-");
                    }else if(mat[j][i] == '|'){
                        if(len & 1) printf("-");
                        else printf("|");
                    }else printf("+");
                } printf("
    ");
            }
        }
    }
    int main(){
        int T;
        scanf("%d", &T);
        while(T --){
            scanf("%d %d", &n, &m);
            for(int i = 0; i < n; i++)
                scanf("%s", mat[i]);
            scanf("%s", op);
            Work();
            printf("
    ");
        }
    }

    填空题 

    #include<bits/stdc++.h>
     
    using namespace std;
     
    const int N = 1e4 + 5;
     
    int pre[N];
    int Find(int x){
        return (pre[x] == x ? x: pre[x] = Find(pre[x]));
    }
     
    void Merge(int x, int y){
        x = Find(x); y = Find(y);
        if(x != y) pre[y] = x;
    }
     
    int main(){
      cout << 'a' <<'c' << endl;
    }

    强迫症的序列

    #include<algorithm>
    #include<iostream>
    #include<vector>
     
     
    using namespace std;
     
    vector<long long> v;
     
     
    int main(){
        int n, T;
        long long x;
        scanf("%d", &T);
        while(T--){
            scanf("%d", &n);
            v.clear();
            for(int i = 0; i < n; i++){
                scanf("%lld", &x);
                v.push_back(x);
            }
            sort(v.begin(), v.end());
            long long cnt = 0;
            for(int i = 1; i < n; i++)
                cnt += v[i] - v[0];
     
            long long sum = 0;
     
            for(int i = 0; i < n - 1; i++)
                sum += v[n-2] - v[i];
     
            printf("%lld %lld
    ", cnt,cnt + v[0]);
        }
     
    }

    用来作弊的药水

    #include<algorithm>
    #include<iostream>
    #include<vector>
     
     
    using namespace std;
    using LL = long long;
     
     
    LL QuickMod(LL x, LL n, LL mod){
        LL ret = 1;
        while(n > 0){
            if(n & 1) ret = ret * x % mod;
            x = x * x %  mod;
            n >>= 1;
        }
        return ret;
    }
     
    int main(){
        int T;
        LL x, a, y, b;
        cin >> T;
        while(T --){
            cin >> x >> a >> y >> b;
            bool flag = true;
            for(int i = 1; i <= 100; i++){
                LL mod = rand() + 1;
                LL c1 = QuickMod(x, a, mod);
                LL c2 = QuickMod(y, b, mod);
                if(c1 != c2) {flag = false; break; }
            }
            if(flag) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
  • 相关阅读:
    HTTP网页错误代码大全带解释
    记录一下手把手教您做电商网站
    C#中的Attribute
    C#中dynamic的正确用法
    【CSP】最大的矩形
    【CSP】字符与int
    C++数组初始化
    C++中输出字符到文本文档
    C++ 中时钟函数的使用
    各种函数的头文件
  • 原文地址:https://www.cnblogs.com/Pretty9/p/8641300.html
Copyright © 2011-2022 走看看