Skip to content

Commit 4d694e0

Browse files
committed
「蓝桥」1102 第 21 场小白/强者赛
1 parent 033e05f commit 4d694e0

File tree

9 files changed

+453
-0
lines changed

9 files changed

+453
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int decimalNum = 20241111;
8+
9+
string binaryStr;
10+
while (decimalNum > 0) {
11+
binaryStr += (decimalNum % 2) ? '1' : '0';
12+
decimalNum /= 2;
13+
}
14+
std::reverse(binaryStr.begin(), binaryStr.end());
15+
16+
cout << (binaryStr.empty() ? 0 : binaryStr) << endl;
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+
*/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
15+
int s = 0;
16+
for (const auto &v: a) {
17+
s ^= v;
18+
}
19+
cout << (s == 0 ? "YES" : "NO") << 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--) {
29+
solve();
30+
}
31+
return 0;
32+
}
33+
/*
34+
购物车里的宝贝【算法赛】
35+
*/
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
ll ans = 10 * n;
11+
int L = to_string(n).length();
12+
13+
for (int i = 1; i < 10; ++i) {
14+
ll s = n + i * pow(10, L);
15+
if (s % m == 0 && s < ans) {
16+
ans = s;
17+
}
18+
}
19+
20+
for (int i = 0; i < 10; ++i) {
21+
for (int j = 1; j < L; ++j) {
22+
ll s1 = n / pow(10, j);
23+
ll s2 = n % (ll) pow(10, j);
24+
ll s = s1 * pow(10, j + 1) + i * pow(10, j) + s2;
25+
if (s % m == 0 && s < ans) {
26+
ans = s;
27+
}
28+
}
29+
}
30+
31+
cout << ans << 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--) {
41+
solve();
42+
}
43+
return 0;
44+
}
45+
/*
46+
代金券【算法赛】
47+
*/
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
15+
std::sort(a.begin(), a.end());
16+
ll ans = std::accumulate(a.begin(), a.end(), 0LL);
17+
18+
if (a[n - 1] > (ans + 1) / 2) {
19+
ll tg = a[n - 1] - (ans - a[n - 1]);
20+
ans += tg - 1;
21+
}
22+
cout << ans << endl;
23+
}
24+
25+
signed main() {
26+
ios::sync_with_stdio(false);
27+
cin.tie(nullptr);
28+
29+
int t = 1;
30+
// cin >> t;
31+
while (t--) {
32+
solve();
33+
}
34+
return 0;
35+
}
36+
/*
37+
蓝桥商场【算法赛】
38+
*/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int n, m;
8+
cin >> n >> m;
9+
10+
vector<int> l(n), r(n);
11+
for (int i = 0; i < n; ++i) {
12+
cin >> l[i] >> r[i];
13+
}
14+
15+
auto st = l, ed = r;
16+
std::sort(st.begin(), st.end());
17+
std::sort(ed.begin(), ed.end());
18+
19+
for (int i = 0; i < n; ++i) {
20+
int x = n - (std::upper_bound(st.begin(), st.end(), r[i]) - st.begin());
21+
int y = std::lower_bound(ed.begin(), ed.end(), l[i]) - ed.begin();
22+
cout << (n - 1 - x - y) << endl;
23+
}
24+
}
25+
26+
signed main() {
27+
ios::sync_with_stdio(false);
28+
cin.tie(nullptr);
29+
30+
int t = 1;
31+
// cin >> t;
32+
while (t--) {
33+
solve();
34+
}
35+
return 0;
36+
}
37+
/*
38+
蓝桥派对【算法赛】
39+
*/
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+
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+
void solve() {
18+
int l, r;
19+
cin >> l >> r;
20+
21+
ll ans = 0;
22+
for (int i = l + 1; i <= r; ++i) {
23+
ans += ksm(i - 1, i - 1) * ksm(i, i) % mod;
24+
ans %= mod;
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--) {
36+
solve();
37+
}
38+
return 0;
39+
}
40+
/*
41+
薅羊毛【算法赛】
42+
*/
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
const int N = 2e5 + 7;
18+
ll inv2;
19+
ll p[N];
20+
21+
void solve() {
22+
ll n;
23+
cin >> n;
24+
25+
ll ans = (ksm(2, n) - 2 + mod) % mod * inv2 % mod * p[n] % mod * 360 % mod;
26+
cout << ans << endl;
27+
}
28+
29+
signed main() {
30+
ios::sync_with_stdio(false);
31+
cin.tie(nullptr);
32+
33+
inv2 = ksm(2, mod - 2);
34+
p[1] = 1;
35+
for (int i = 1; i <= 2e5; ++i) {
36+
p[i] = p[i - 1] * 10 + 1;
37+
p[i] %= mod;
38+
}
39+
40+
int t = 1;
41+
cin >> t;
42+
while (t--) {
43+
solve();
44+
}
45+
return 0;
46+
}
47+
/*
48+
中奖编号【算法赛】
49+
*/
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
const int mod = 1e9 + 7;
6+
const int N = 1e5 + 7;
7+
8+
int vis[N];
9+
10+
void solve() {
11+
int n;
12+
cin >> n;
13+
14+
ll ans = 1;
15+
for (int i = 2; i <= n; ++i) {
16+
if (!vis[i]) {
17+
int cnt = 0;
18+
for (int j = i; j <= n; j *= i) {
19+
cnt += n / j;
20+
}
21+
ans *= cnt + 1;
22+
ans %= mod;
23+
}
24+
}
25+
cout << ans << endl;
26+
}
27+
28+
signed main() {
29+
ios::sync_with_stdio(false);
30+
cin.tie(nullptr);
31+
32+
for (ll i = 2; i <= 1e5; ++i) {
33+
if (!vis[i]) {
34+
for (ll j = i * i; j <= 1e5; j += i) {
35+
vis[j] = 1;
36+
}
37+
}
38+
}
39+
40+
int t = 1;
41+
// cin >> t;
42+
while (t--) {
43+
solve();
44+
}
45+
return 0;
46+
}
47+
/*
48+
凑单返现【算法赛】
49+
*/

0 commit comments

Comments
 (0)