ccfcsp-202006(4、5)

202006-4 1246

32分解

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    string str1 = "1";
    for(int i = 0; i < n; i++){
        string str2 = "";
        for(int j = 0; j < str1.size(); j++){
            if(str1[j] == '1')
                str2 += '2';
            if(str1[j] == '2')
                str2 += '4';
            if(str1[j] == '4')
                str2 += "16";
            if(str1[j] == '6')
                str2 += "64";
        }
        str1 = str2;
    }
    int res = 0;
    int pos = 0;
    while(str1.find(s, pos) != -1){
        res++;
        pos = str1.find(s, pos) + 1;
    }
    cout << res;
    return 0;
}

202006-5 乔乔和牛牛逛超市

80分解

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int a[n][5], b[m][3];
    long long Max[n], res = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 5; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        Max[i] = a[i][0] * a[i][0] * a[i][2] + a[i][0] * a[i][3] + a[i][4];
        for(int j = a[i][0]; j <= a[i][1]; j++){
            if(j * j * a[i][2] + j * a[i][3] + a[i][4] > Max[i]){
                Max[i] = j * j * a[i][2] + j * a[i][3] + a[i][4];
            }
        }
    }
    for(int i = 0; i< n;i++){
        res += Max[i];
    }
    cout << res;
    return 0;
}
相关推荐
雾月5524 分钟前
LeetCode 1292 元素和小于等于阈值的正方形的最大边长
java·数据结构·算法·leetcode·职场和发展
OpenC++1 小时前
【C++QT】Buttons 按钮控件详解
c++·经验分享·qt·leetcode·microsoft
YuforiaCode2 小时前
第十二届蓝桥杯 2021 C/C++组 直线
c语言·c++·蓝桥杯
知来者逆2 小时前
计算机视觉——速度与精度的完美结合的实时目标检测算法RF-DETR详解
图像处理·人工智能·深度学习·算法·目标检测·计算机视觉·rf-detr
阿让啊2 小时前
C语言中操作字节的某一位
c语言·开发语言·数据结构·单片机·算法
এ᭄画画的北北2 小时前
力扣-160.相交链表
算法·leetcode·链表
草莓啵啵~3 小时前
搜索二叉树-key的搜索模型
数据结构·c++
共享家95273 小时前
深入理解C++ 中的list容器
c++
孞㐑¥3 小时前
C++11介绍
开发语言·c++·经验分享·笔记
云小逸3 小时前
【QQMusic项目界面开发复习笔记】第二章
c++·qt