团体程序设计天梯赛-练习集 L1-065——L1-072

团体程序设计天梯赛-练习集

  1. /*
     * @Description: 不要废话上代码
     * @version: 
     * @Author: 
     * @Date: 2021-03-27 09:33:36
     * @LastEditors: Please set LastEditors
     * @LastEditTime: 2021-03-27 09:34:34
     */
    #include <iostream>
    using namespace std;
    int main(void)
    {
        cout << "Talk is cheap. Show me the code." << endl;
        return 0;
    }
    
  2. /*
     * @Description: 猫是液体
     * @version: 
     * @Author: 
     * @Date: 2021-03-27 09:35:45
     * @LastEditors: Please set LastEditors
     * @LastEditTime: 2021-03-27 09:36:34
     */
    #include <iostream>
    using namespace std;
    int main(void)
    {
        int a, b, c;
        cin >> a >> b >> c;
        cout << a * b * c << endl;
        return 0;
    }
    
  3. /*
     * @Description: 洛希极限
     * @version: 
     * @Author: 
     * @Date: 2021-03-27 09:40:51
     * @LastEditors: Please set LastEditors
     * @LastEditTime: 2021-03-27 09:46:24
     */
    #include <iostream>
    #include <cstdio>
    using namespace std;
    int main(void)
    {
        float a, b;
        // a是两天体密度比值的三次方,b是两天体具体比大天体半径
        int type;
        cin >> a >> type >> b;
        if (type == 0)
        {
            // cout << a * 2.455 << " ";
            printf("%.2f ", a * 2.455);
            if (a * 2.455 >= b)
                cout << "T_T" << endl;
            else
                cout << "^_^" << endl;
        }
        else if (type == 1)
        {
            printf("%.2f ", a * 1.26);
            if (a * 1.26 >= b)
                cout << "T_T" << endl;
            else
                cout << "^_^" << endl;
        }
        return 0;
    }
    
  4. /*
     * @Description: 调和平均数
     * @version: 
     * @Author: 
     * @Date: 2021-03-27 09:48:00
     * @LastEditors: Please set LastEditors
     * @LastEditTime: 2021-03-27 09:53:59
     */
    #include <iostream>
    #include <cstdio>
    using namespace std;
    int main(void)
    {
        int n;
        float sum = 0.0F;
        cin >> n;
        for (int i = 0; i < n; i++)
        {
            float num;
            cin >> num;
            sum += 1.0 / num;
        }
        printf("%.2f\n", 1.0 / (sum / n));
        return 0;
    }
    
  5. /*
     * @Description: 监测胎压
     * @version: 
     * @Author: 
     * @Date: 2021-03-27 09:54:39
     * @LastEditors: Please set LastEditors
     * @LastEditTime: 2021-03-27 10:28:44
     */
    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    bool check(int w, int maxw, int min, int sub)
    {
        if (maxw - w <= sub && w >= min)
            return true;
        return false;
    }
    int main(void)
    {
        int w1, w2, w3, w4, min, sub;
        cin >> w1 >> w2 >> w3 >> w4 >> min >> sub;
        vector<int> w;
        w.push_back(w1);
        w.push_back(w2);
        w.push_back(w3);
        w.push_back(w4);
        int count = 0;
        int error;
        sort(w.begin(), w.end());
        for (int i = 0; i < 4; i++)
        {
            if (!check(w[i], w[3], min, sub))
            {
                count++;
                error = w.at(i);
            }
        }
        if (count == 0)
            cout << "Normal" << endl;
        else if (count == 1)
        {
            if (error == w1)
                cout << "Warning: please check #1!" << endl;
            else if (error == w2)
                cout << "Warning: please check #2!" << endl;
            else if (error == w3)
                cout << "Warning: please check #3!" << endl;
            else if (error == w4)
                cout << "Warning: please check #4!" << endl;
        }
        else if (count >= 2)
            cout << "Warning: please check all the tires!" << endl;
        return 0;
    }
    
    
  6. /*
     * @Description: 吃火锅
     * @version: 
     * @Author: 
     * @Date: 2021-03-27 10:28:49
     * @LastEditors: Please set LastEditors
     * @LastEditTime: 2021-03-27 10:41:51
     */
    #include <string>
    #include <iostream>
    using namespace std;
    int main(void)
    {
        int sum_count = 0, target_count = 0, first_occur = -1;
        while (true)
        {
            string str;
            getline(cin, str);
            if (str == ".")
                break;
            sum_count++;
            if (str.find("chi1 huo3 guo1") != string::npos)
            {
                target_count++;
                if (first_occur == -1)
                    first_occur = sum_count;
            }
        }
        if (target_count == 0)
            cout << sum_count << "\n"
                 << "-_-#" << endl;
    
        else if (target_count != 0)
            cout << sum_count << "\n"
                 << first_occur << " " << target_count << endl;
        return 0;
    }
    
  7. /*
     * @Description: 前世档案
     * @version:
     * @Author:
     * @Date: 2021-03-27 10:48:42
     * @LastEditors: Please set LastEditors
     * @LastEditTime: 2021-03-27 12:31:56
     */
    struct treeNode
    {
        int left;
        int right;
    };
    #include <iostream>
    #include <vector>
    #include <math.h>
    #include <string>
    using namespace std;
    int main(void)
    {
        /* 
        在30层二叉树中就会导致内存超限
        int n, person;
        cin >> n >> person;
        vector<struct treeNode> v;
        struct treeNode temp;
        temp.left = 0;
        temp.right = 0;
        v.push_back(temp);
        int t = (int)pow(2, n);
        for (int i = 1; i < t; i++)
        {
            temp.left = i * 2;
            temp.right = i * 2 + 1;
            v.push_back(temp);
        }
        for (int i = 0; i < person; i++)
        {
            string str;
            cin >> str;
            int answer;
            int root = 1;
            for (int j = 0; j < n; j++)
            {
                if (str[j] == 'y')
                {
                    answer = v[root].left;
                    root = v[root].left;
                }
                else if (str[j] == 'n')
                {
                    answer = v[root].right;
                    root = v[root].right;
                }
            }
            cout << answer - (int)pow(2, n) + 1 << endl;
        } */
        int n, person;
        cin >> n >> person;
        for (int i = 0; i < person; i++)
        {
            string str;
            cin >> str;
            int res = 1;
            for (int j = 0; j < n; j++)
            {
                if (str[j] == 'y')
                    res *= 2;
                else if (str[j] == 'n')
                    res = res * 2 + 1;
            }
            cout << res - (int)pow(2, n) + 1 << endl;
        }
        return 0;
    }
    /* 
    30 4
    ynyynyynyynyynyynyynyynyynyyny
    nyynyynyynyynyynyynyynyynyynyy
    nynnyynyynyynyynyynyynyynyynyy
    yynyynyynyynyynyynyynyynyynyyn
     */
    
  8. /*
     * @Description: 刮刮彩票
     * @version: 
     * @Author: 
     * @Date: 2021-03-27 12:35:46
     * @LastEditors: Please set LastEditors
     * @LastEditTime: 2021-03-27 12:53:14
     */
    #include <iostream>
    #include <map>
    using namespace std;
    int sum_row(int current[][3], int n)
    {
        return current[n][0] + current[n][1] + current[n][2];
    }
    int sum_col(int current[][3], int n)
    {
        return current[0][n] + current[1][n] + current[2][n];
    }
    int main(void)
    {
        int current[3][3];
        map<int, int> m;
        m[6] = 10000;
        m[7] = 36;
        m[8] = 720;
        m[9] = 360;
        m[10] = 80;
        m[11] = 252;
        m[12] = 108;
        m[13] = 72;
        m[14] = 54;
        m[15] = 180;
        m[16] = 72;
        m[17] = 180;
        m[18] = 119;
        m[19] = 36;
        m[20] = 306;
        m[21] = 1080;
        m[22] = 144;
        m[23] = 1800;
        m[24] = 3600;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
                cin >> current[i][j];
        }
        int blank = 45;
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
                if (current[i][j] != 0)
                    blank -= current[i][j];
        }
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
                if (current[i][j] == 0)
                    current[i][j] = blank;
        }
        for (int i = 0; i < 3; i++)
        {
            int x, y;
            cin >> x >> y;
            cout << current[x - 1][y - 1] << endl;
        }
        int choice;
        cin >> choice;
        int sum = 0;
        if (choice == 7)
            sum = current[0][0] + current[1][1] + current[2][2];
        else if (choice == 8)
            sum = current[2][0] + current[1][1] + current[0][2];
        else if (choice < 4)
            sum = sum_row(current, choice - 1);
        else if (choice < 7)
            sum = sum_col(current, choice - 4);
        cout << m[sum] << endl;
        return 0;
    }
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jian圣楠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值