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 3f1cdea

Browse files
committed
「蓝桥」0125 第 25 场 蓝桥月赛
1 parent 2587bf8 commit 3f1cdea

File tree

6 files changed

+254
-0
lines changed

6 files changed

+254
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
cout << 11 << 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+
*/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int n, x;
8+
cin >> n >> x;
9+
10+
while (n--) {
11+
int l, w;
12+
cin >> l >> w;
13+
14+
int ans = l * w;
15+
while (ans % 2 == 0 && ans > x) {
16+
ans /= 2;
17+
}
18+
cout << (ans == x ? "Yes" : "No") << endl;
19+
}
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+
*/
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+
void solve() {
7+
int n;
8+
cin >> n;
9+
10+
vector<int> a(n);
11+
for (int i = 0; i < n; ++i) {
12+
cin >> a[i];
13+
}
14+
std::sort(a.begin(), a.end());
15+
16+
int ans = (a[0] + a[n - 1]) / 2;
17+
cout << ans << endl;
18+
}
19+
20+
signed main() {
21+
ios::sync_with_stdio(false);
22+
cin.tie(nullptr);
23+
24+
int t = 1;
25+
// cin >> t;
26+
while (t--) solve();
27+
return 0;
28+
}
29+
/*
30+
过年【算法赛】
31+
*/
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+
int n;
8+
cin >> n;
9+
10+
vector<int> a(n);
11+
for (int i = 0; i < n; ++i) {
12+
cin >> a[i];
13+
}
14+
vector<int> b = a;
15+
std::sort(b.begin(), b.end());
16+
17+
int cur = 0;
18+
int ans = 0;
19+
for (int i = 0; i < n; ++i) {
20+
if (a[i] != b[cur]) {
21+
ans++;
22+
} else {
23+
cur++;
24+
}
25+
}
26+
cout << ans << endl;
27+
}
28+
29+
signed main() {
30+
ios::sync_with_stdio(false);
31+
cin.tie(nullptr);
32+
33+
int t = 1;
34+
// cin >> t;
35+
while (t--) solve();
36+
return 0;
37+
}
38+
/*
39+
喜糖摆放【算法赛】
40+
*/
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
const int MAX = 1e3 + 7;
7+
int a[MAX][MAX], dp[MAX][MAX];
8+
9+
void solve() {
10+
int n;
11+
cin >> n;
12+
13+
for (int i = 0; i <= n + 1; ++i) {
14+
for (int j = 0; j <= n + 1; ++j) {
15+
dp[i][j] = 1e9;
16+
}
17+
a[0][i] = a[i][0] = -1;
18+
}
19+
20+
for (int i = 1; i <= n; ++i) {
21+
for (int j = 1; j <= n; ++j) {
22+
int x;
23+
cin >> x;
24+
if (x & 1) {
25+
a[i][j] = 1;
26+
} else {
27+
a[i][j] = 0;
28+
}
29+
}
30+
}
31+
32+
dp[1][1] = (a[1][1] ? 0 : n);
33+
34+
for (int i = 1; i <= n; ++i) {
35+
for (int j = 1; j <= n; ++j) {
36+
dp[i][j] = min(dp[i][j], dp[i - 1][j] + (a[i][j] == 0) * n);
37+
if (a[i][j] == a[i][j - 1]) {
38+
dp[i][j] = min(dp[i][j], dp[i][j - 1]);
39+
}
40+
}
41+
}
42+
43+
if (dp[n][n] == 1e9) {
44+
cout << "NO!" << endl;
45+
} else {
46+
cout << dp[n][n] << endl;
47+
}
48+
}
49+
50+
signed main() {
51+
ios::sync_with_stdio(false);
52+
cin.tie(nullptr);
53+
54+
int t = 1;
55+
cin >> t;
56+
while (t--) solve();
57+
return 0;
58+
}
59+
/*
60+
舞狮表演【算法赛】
61+
*/
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
const int mod = 1e9 + 7;
6+
7+
ll ksm(ll x, ll k, ll mo = mod) {
8+
ll ans = 1;
9+
while (k) {
10+
if (k & 1) ans = ans * x % mo;
11+
x = x * x % mo;
12+
k >>= 1;
13+
}
14+
return ans;
15+
}
16+
17+
int one;
18+
int a[32];
19+
ll dp[32][2][2][32];
20+
21+
ll dfs(int len, int limit, int zero, int cnt) {
22+
if (!len) return cnt == one;
23+
if (~dp[len][limit][zero][cnt]) return dp[len][limit][zero][cnt];
24+
ll res = 0;
25+
int up = limit ? a[len] : 1;
26+
for (int i = 0; i <= up; ++i) {
27+
res += dfs(len - 1, limit && i == up, zero && !i, cnt + i);
28+
res %= mod;
29+
}
30+
return dp[len][limit][zero][cnt] = res;
31+
}
32+
33+
ll f(int x) {
34+
memset(dp, -1, sizeof(dp));
35+
int len = 0;
36+
while (x) {
37+
a[++len] = x % 2;
38+
x /= 2;
39+
}
40+
return dfs(len, 1, 1, 0);
41+
}
42+
43+
void solve() {
44+
int n, k;
45+
cin >> n >> k;
46+
47+
ll ans = 1;
48+
for (int i = 1; i < 31; ++i) {
49+
one = i;
50+
51+
ans += ksm(n, i) * f(k) % mod;
52+
ans %= mod;
53+
}
54+
cout << ans << endl;
55+
}
56+
57+
signed main() {
58+
ios::sync_with_stdio(false);
59+
cin.tie(nullptr);
60+
61+
int t = 1;
62+
// cin >> t;
63+
while (t--) solve();
64+
return 0;
65+
}
66+
/*
67+
知识考量码【算法赛】
68+
*/

0 commit comments

Comments
(0)

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