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;
}
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;
}