# 第十四届蓝桥杯三月真题刷题训练——第 11 天（3.14）

Think_bird 2023-03-14 13:34:31

## 卡片

``````#include<bits/stdc++.h>

using namespace std;

int main()
{
for(int i = 1, j = 2021, pd = true; pd; i ++ )
{
string a = to_string(i);
for(int i = 0; i < a.size(); i ++ ) if(a[i] - '0' == 1) j --;
if(!j) cout << i, pd = false;
}

return 0;
}``````

## 路径

``````#include <bits/stdc++.h>
using namespace std;

int ans[2022];
int lcm(int x, int y) {return x * y / __gcd(x, y);}

int main()
{
for(int i = 1; i <= 2021; i++)
for(int j = i + 1; j <= i + 21 && j <= 2021; j ++ )
if(!ans[j]) ans[j] = ans[i] + lcm(i, j);
else ans[j] = min(ans[j], ans[i] + lcm(i, j));
cout << ans[2021];

return 0;
}``````

## 字符统计

``````#include <bits/stdc++.h>

using namespace std;

string a;
vector<pair<int, char>> ans;

int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> a;
sort(a.begin(), a.end());
ans.push_back({1, a[0]});
for(int i = 1; i < a.size(); i ++ )
if(a[i] == a[i - 1]) ans[ans.size() - 1].first ++;
else ans.push_back({1, a[i]});
sort(ans.begin(), ans.end());
int max = ans[ans.size() - 1].first;
for(int i = 0; i < ans.size(); i ++ )
if(ans[i].first == max) cout << ans[i].second;

return 0;
}``````

## 费用报销

``````#include<bits/stdc++.h>

using namespace std;

int n, m, k, y, r, v;
int day[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
int dp[366];

int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m >> k;
for (int i = 0; i < n; i ++ )
{
cin >> y >> r >> v;
dp[day[y - 1] + r] = max(dp[day[y - 1] + r], v);
}

for (int i = 1; i <= 365; i ++ )
if(dp[i] + dp[max(i - k, 0)] <= m) dp[i] = max(dp[i] + dp[max(i - k, 0)], dp[i - 1]);
else dp[i] = dp[i - 1];
cout << dp[365] << "\n";

}
``````
...全文
9 回复 打赏 收藏 举报

4.1w+

2023-03-14 13:34

刷题！