• 9.11 拉练


    A签到 练习赛 - Virtual Judge (ppsucxtt.cn)

    原链接 Div2 A, 难度800 Problem - 1554A - Codeforces

    题意

    t组数据中给出一个n(1~1e9),然后是长度为n的数列,求选定一段区间内最大值和最小值之积 最大。 区间范围:1l<rn

    题解

    不需要每个区间都遍历,只取相邻两个数的最大值即可。毕竟最大值附近越往外扩张最小值小的几率更大。

    #include <string>
    #include <iostream>
    #include <cmath>
    
    using namespace std;
    typedef long long LL;
    
    int main()
    {
        int t;
        cin >> t;
        while(t --)
        {
            LL n, l, r, res = 0;
            cin >> n >> l;
            for(LL i = 1; i < n; i ++)
            {
                cin >> r;    
                res = max(res, l*r);
                l = r;
            }
                
            cout << res <<endl;
                
            
        }
        
        return 0;
    }

    B最难的一个,思维题 练习赛 - Virtual Judge (ppsucxtt.cn)

    原链接 Div2 C难度1600 Problem - 1567C - Codeforces

    题意

    给出你一个n让你求出有多少对a,b,(a,b颠倒位置也算一种)相加构成,运算规则:如果有进位将其进到前面两位的地方

    题解

    它的奇数会进到奇数位前一位,偶数也是,所以可以将题n为奇数位(记为x)和偶数位(记为y)组成的数字,如2021化为01和22,n为0~x 和0~y相加得到

    结果输出:(x+1)*(y+1)-2     2是因为两个数不能有任意一数=0

    #include <string>
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <set>
    #include <cmath>
    
    using namespace std;
    typedef long long LL;
    int a[30];
    
    int main()
    {
        int t;
        cin >> t;
        while(t --)
        {
            int n, odd = 0, even = 0;
            cin >> n;
            
            int n1 = n, len = 0, index = 1;//不进位
            while(n1)
            {
                if(n1>9)
                    index *= 10;
                    
                len ++;
                n1/=10;
            }
            for(int i = len; i>0; i --)
            {
                if(i%2==1)//odd
                    odd = odd*10+n/index;
                else
                    even = even*10+n/index;
                n%=index; 
                index/=10;
            }
            
            // cout << odd << "  "<<even<<endl;
            cout << (odd+1)*(even+1)-2 <<endl;
        }
        
        return 0;
    }

     C也算一个签到题,但是有小坑  练习赛 - Virtual Judge (ppsucxtt.cn)

    原链接 Div2 A 900  Problem - 1555A - Codeforces

    题意+题解

    n个人切n块,不能切也可以>n块

    可以把饼切成6 8 10块, 分别需15 20 25分钟,其实都是一块需5/2分钟,但是最少切六下

    8 10存在的意义就是n>10时,奇数+1就可以正好切,偶数也可以正好切

    #include <string>
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <set>
    #include <cmath>
    
    using namespace std;
    typedef long long LL;
    
    int main()
    {
        int t;
        cin >> t;
        while(t --)
        {
            LL n;
            cin >> n;
            if(n<=6)
            cout << 15<<endl;
            else if(n<=8)
            cout << 20 << endl;
            else if(n<=10)
            cout << 25<<endl;
            else
            {
                n = (n+1)>>1;
                cout << n*(LL)5<<endl;
            }        
        }
        return 0;
    }
  • 相关阅读:
    IDEA、Eclipse快捷键对比
    linux常见命令
    拷贝本地文件到远程服务器的批处理脚本
    关系型数据库的超键、候选键、主键
    JAVA运算符总结
    JAVA原码反码补码
    JPA查询语句(转载)
    Spring Data JPA初使用(转载)
    android学习————项目导入常见错误整理(转载)
    Spring 系列: Spring 框架简介
  • 原文地址:https://www.cnblogs.com/la-la-wanf/p/15256947.html
Copyright © 2020-2023  润新知