Skip to content

Commit 60e3e75

Browse files
committed
「蓝桥」0419 第 28 场 蓝桥月赛
1 parent 80eab40 commit 60e3e75

File tree

6 files changed

+240
-0
lines changed

6 files changed

+240
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int red = 123;
8+
int yellow = 456;
9+
int blue = 789;
10+
11+
int green = min(yellow, blue);
12+
int ans = red + yellow + blue - green;
13+
cout << ans << endl;
14+
}
15+
16+
signed main() {
17+
ios::sync_with_stdio(false);
18+
cin.tie(nullptr);
19+
20+
int t = 1;
21+
// cin >> t;
22+
while (t--) solve();
23+
return 0;
24+
}
25+
26+
/*
27+
发射火箭【算法赛】
28+
*/
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int n;
8+
cin >> n;
9+
10+
// 存储每天的燃油消耗
11+
vector<ll> A(n + 1), B(n + 1);
12+
// 前缀和数组
13+
vector<ll> prefix_A(n + 1, 0), prefix_B(n + 1, 0);
14+
15+
for (int i = 1; i <= n; ++i) {
16+
cin >> A[i];
17+
}
18+
for (int i = 1; i <= n; ++i) {
19+
cin >> B[i];
20+
}
21+
22+
// 读入燃油消耗
23+
for (int i = 1; i <= n; ++i) {
24+
// 计算前缀和
25+
prefix_A[i] = prefix_A[i - 1] + A[i];
26+
prefix_B[i] = prefix_B[i - 1] + B[i];
27+
}
28+
29+
// 初始最小消耗:全程用A或B
30+
ll min_cost = min(prefix_A[n], prefix_B[n]);
31+
32+
// 情况1:从A切换到B
33+
for (int k = 1; k < n; ++k) {
34+
ll cost = prefix_A[k] + (prefix_B[n] - prefix_B[k]);
35+
min_cost = min(min_cost, cost);
36+
}
37+
// 情况2:从B切换到A
38+
for (int k = 1; k < n; ++k) {
39+
ll cost = prefix_B[k] + (prefix_A[n] - prefix_A[k]);
40+
min_cost = min(min_cost, cost);
41+
}
42+
43+
// 输出结果
44+
cout << min_cost << endl;
45+
}
46+
47+
signed main() {
48+
ios::sync_with_stdio(false);
49+
cin.tie(nullptr);
50+
51+
int t = 1;
52+
// cin >> t;
53+
while (t--) solve();
54+
return 0;
55+
}
56+
57+
/*
58+
燃油交换【算法赛】
59+
*/
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int n, d;
8+
cin >> n >> d;
9+
10+
set<int> s;
11+
for (int i = 0; i < n; ++i) {
12+
int x;
13+
cin >> x;
14+
s.insert(x);
15+
}
16+
17+
int res = 0;
18+
set<int> t;
19+
for (int v: s) {
20+
if (!t.count(v)) {
21+
int g = v;
22+
int ans = 0;
23+
while (s.count(g) && !t.count(g)) {
24+
ans++;
25+
t.insert(g);
26+
g += d;
27+
}
28+
res += (ans + 1) / 2;
29+
}
30+
}
31+
cout << res << endl;
32+
}
33+
34+
signed main() {
35+
ios::sync_with_stdio(false);
36+
cin.tie(nullptr);
37+
38+
int t = 1;
39+
// cin >> t;
40+
while (t--) solve();
41+
return 0;
42+
}
43+
44+
/*
45+
训练反应力【算法赛】
46+
*/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int n;
8+
cin >> n;
9+
vector<int> a(n - 1);
10+
for (auto &i: a) {
11+
cin >> i;
12+
}
13+
14+
int res = 0, p = 0;
15+
while (a[p] != n) {
16+
res++;
17+
p = max_element(a.begin() + p, a.begin() + a[p]) - a.begin();
18+
}
19+
cout << res + 1 << endl;
20+
}
21+
22+
signed main() {
23+
ios::sync_with_stdio(false);
24+
cin.tie(nullptr);
25+
26+
int t = 1;
27+
// cin >> t;
28+
while (t--) solve();
29+
return 0;
30+
}
31+
32+
/*
33+
最佳航线【算法赛】
34+
*/
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
const int mod = 1e9 + 7;
7+
8+
void solve() {
9+
int n;
10+
cin >> n;
11+
vector<int> a(n);
12+
for (int i = 0; i < n; ++i) {
13+
cin >> a[i];
14+
}
15+
if (n > 3000) {
16+
cout << 0 << endl;
17+
return;
18+
}
19+
20+
ll ans = 1;
21+
for (int i = 0; i < n; ++i) {
22+
for (int j = i + 1; j < n; ++j) {
23+
ans *= (a[i] ^ a[j]);
24+
ans %= mod;
25+
}
26+
}
27+
cout << ans << endl;
28+
}
29+
30+
signed main() {
31+
ios::sync_with_stdio(false);
32+
cin.tie(nullptr);
33+
34+
int t = 1;
35+
// cin >> t;
36+
while (t--) solve();
37+
return 0;
38+
}
39+
40+
/*
41+
航天梦【算法赛】
42+
*/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
const int mod = 1e9 + 7;
7+
8+
void solve() {
9+
ll a, b, c;
10+
cin >> a >> b >> c;
11+
12+
if (a > c) {
13+
cout << b + c * 2 << endl;
14+
} else {
15+
cout << b / 2 * 2 + a * 2 + (c - a) / 2 << endl;
16+
}
17+
}
18+
19+
signed main() {
20+
ios::sync_with_stdio(false);
21+
cin.tie(nullptr);
22+
23+
int t = 1;
24+
cin >> t;
25+
while (t--) solve();
26+
return 0;
27+
}
28+
29+
/*
30+
吃零食训练【算法赛】
31+
*/

0 commit comments

Comments
 (0)