# 2023.3.14 30天蓝桥训练打卡题目 day 11

szx233 2023-03-14 11:04:33

``````#include<iostream>
using namespace std;
typedef long long ll;
int b[11];

int main()
{
for(int i = 0; i <= 9; i ++ ) b[i] = 2021;
for(int i = 1; ; i ++ )
{
int r = i;
while(r)
{
int u = r % 10;
if(!b[u])
{
cout << i - 1;
return 0;
}
b[u] -- ;
r /= 10;
}
}

return 0;
}
``````

``````#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const int N = 3010;
int f[N];

int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}

int main()
{
memset(f, 0x3f3f3f3f, sizeof f);
int n = 2021;
f[1] = 0;
for(int i = 1; i <= n; i ++ )
for(int j = 1; j < i; j ++ )
if(i - j <= 21)
f[i] = min(f[i], f[j] + i * j / gcd(i, j));
cout << f[2021];

return 0;
}
``````

``````#include<iostream>
using namespace std;
typedef long long ll;
int b[30];

int main()
{
string s;
cin >> s;
int t = s.size();
for(int i = 0; i < t; i ++ ) b[s[i] - 'A'] ++ ;
int ma = 0;
for(int i = 0; i < 26; i ++ ) ma = max(ma, b[i]);
for(int i = 0; i < 26; i ++ )
if(b[i] == ma) cout << (char)(i + 'A');

return 0;
}
``````

``````#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1010;
typedef pair<int, int> PII;
PII p[N];
int n, M, k;
int b1[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int s1[13];
int f[N][5010];
// v[i] - 物品体积+价值
// M - 背包总体积
bool cmp(PII x, PII y)
{
return x.first < y.first;
}
int main()
{
for(int i = 1; i <= 12; i ++ ) s1[i] = s1[i - 1] + b1[i];
cin >> n >> M >> k;
int x, y, z;
for(int i = 1; i <= n; i ++ )
{
cin >> x >> y >> p[i].second;
p[i].first = s1[x - 1] + y;
}
sort(p + 1, p + n + 1, cmp);

int l = 0;
for(int i = 1; i <= n; i ++ )
{
while(p[i].first - p[l + 1].first >= k) l ++ ;
for(int j = M; j >= p[i].second; j -- )
if(j < p[i].second) f[i][j] = f[i - 1][j];
else
{
f[i][j] = max(f[i - 1][j], f[l][j - p[i].second] + p[i].second);
}
}
cout << f[n][M];

return 0;
}``````

...全文
20 回复 打赏 收藏 转发到动态 举报

50,603

• 近7日
• 近30日
• 至今

刷题！