Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 96316ac

Browse files
committed
「蓝桥」0524 第 29 场 蓝桥·算法入门赛
1 parent 60e3e75 commit 96316ac

File tree

6 files changed

+197
-0
lines changed

6 files changed

+197
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
cout << 12 - 4 << endl;
8+
}
9+
10+
signed main() {
11+
ios::sync_with_stdio(false);
12+
cin.tie(nullptr);
13+
14+
int t = 1;
15+
cin >> t;
16+
while (t--) solve();
17+
return 0;
18+
}
19+
20+
/*
21+
不油腻的星座【算法赛】
22+
*/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int a, b, c;
8+
cin >> a >> b >> c;
9+
cout << max(b - a, c - b) - 1 << endl;
10+
}
11+
12+
signed main() {
13+
ios::sync_with_stdio(false);
14+
cin.tie(nullptr);
15+
16+
int t = 1;
17+
cin >> t;
18+
while (t--) solve();
19+
return 0;
20+
}
21+
22+
/*
23+
守护神开会【算法赛】
24+
*/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
ll n, m;
8+
cin >> n >> m;
9+
10+
int ans = 0;
11+
ll sum = 0;
12+
vector<int> a(n);
13+
for (int i = 0; i < n; ++i) {
14+
cin >> a[i];
15+
sum += a[i];
16+
if (sum >= m) {
17+
ans++;
18+
sum = 0;
19+
}
20+
}
21+
if (ans == 0) {
22+
cout << -1 << endl;
23+
} else {
24+
cout << n - ans << endl;
25+
}
26+
}
27+
28+
signed main() {
29+
ios::sync_with_stdio(false);
30+
cin.tie(nullptr);
31+
32+
int t = 1;
33+
// cin >> t;
34+
while (t--) solve();
35+
return 0;
36+
}
37+
38+
/*
39+
守护射手座【算法赛】
40+
*/
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+
void solve() {
7+
int n;
8+
cin >> n;
9+
10+
ll odd = 0, even = 0;
11+
vector<int> a(n);
12+
for (int i = 0; i < n; ++i) {
13+
cin >> a[i];
14+
if (a[i] % 2) {
15+
odd++;
16+
} else {
17+
even++;
18+
}
19+
}
20+
21+
ll sum = accumulate(a.begin(), a.end(), 0LL);
22+
if (sum % 2) {
23+
cout << 0 << endl;
24+
} else {
25+
ll ans = even * (even - 1) / 2 + odd * (odd - 1) / 2 + even * odd;
26+
cout << ans << endl;
27+
}
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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
int A[100007];
7+
8+
void solve() {
9+
int n;
10+
cin >> n;
11+
int ans = 0;
12+
for (int i = 1; i <= n; ++i) {
13+
cin >> A[i];
14+
}
15+
for (int i = 1; i <= n; ++i) {
16+
if (i - 1 >= 1 && !A[i - 1] && !A[i]) {
17+
ans++;
18+
A[i] = 1;
19+
}
20+
if (i - 2 >= 1 && !A[i - 2] && A[i - 1] && !A[i]) {
21+
ans++;
22+
A[i] = 1;
23+
}
24+
}
25+
cout << ans << endl;
26+
}
27+
28+
signed main() {
29+
ios::sync_with_stdio(false);
30+
cin.tie(nullptr);
31+
32+
int t = 1;
33+
// cin >> t;
34+
while (t--) solve();
35+
return 0;
36+
}
37+
38+
/*
39+
狮子座的试炼【算法赛】
40+
*/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
int k = 1;
11+
while (k <= n) {
12+
k *= 2;
13+
}
14+
cout << k - n << endl;
15+
}
16+
17+
signed main() {
18+
ios::sync_with_stdio(false);
19+
cin.tie(nullptr);
20+
21+
int t = 1;
22+
// cin >> t;
23+
while (t--) solve();
24+
return 0;
25+
}
26+
27+
/*
28+
星座解密【算法赛】
29+
*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /