112946317_p0_master1200.jpg
你是抱着多大的觉悟说出这种话的🙄️
你只不过是一个学生,有办法背负其他人的人生吗😡
“什么都愿意做”就是这么沉重的话😡
做不来的事就别轻易说出口😡
你这个人,满脑子都只想到自己呢😒

A

easy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9')
{
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x= x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}

signed main()
{
int n = read();
if(n == 1) {
cout << 1 << endl;
return 0;
} else if(n & 1) {
cout << 1.0 * ((n / 2) + 1) / n << endl;
} else cout << 0.5 << endl;
return 0;
}

B

easy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9')
{
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x= x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}


signed main()
{
int n = read(), k = read();
int ans = 0;
for(int i = 0; i < n; i++) {
int x = read();
if(x >= k) ans++;
}
cout << ans << endl;
return 0;
}

C

easy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9')
{
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x= x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}

signed main() {
int n = read();
vector<int> a(n);
for(int i = 1; i <= n; i++) {
int x = read();
a[x - 1] = i;
};
for(int i = 0; i < n; i++) cout << a[i] << " ";
return 0;
}

D

求质因数个数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9')
{
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x= x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}

signed main() {
int a = read(), b = read();
int gcd = __gcd(a, b);
int ans = 1, n = gcd;
for(int i = 2; i * i <= n; i++)
{
if(gcd % i == 0) {
ans++;
while(gcd % i == 0) gcd /= i;
}
}
if(gcd != 1) ans++;
cout << ans << endl;
return 0;
}

e

状压
二进制位表示可以开的箱子
枚举每个商店,二进制数w表示钥匙可以开哪些箱子,并统计目前可以打开的个数
枚举可以到达该状态的所有状态,更新花费,即if((w | j) == w) dp[j] = min(dp[j], a);
判断有没有解
在枚举所有状态,枚举转移路径

1
2
3
for(int i = 0; i < (1 << n); i++)
for(int j = 0; j <= i; j++)
dp[i] = min(dp[i], dp[i ^ j] + dp[j]);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9')
{
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x= x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}

signed main()
{
int n = read(), m = read();
int tot = 0;
vector<int> dp(1 << (n + 1) + 10, 0x3f3f3f3f);
vector<bool> st(n + 1);
for(int i = 0; i < m; i++)
{
int a = read(), b = read(), w = 0;
for(int j = 0; j < b; j++)
{
int c = read();
w += 1 << (c - 1);
if(!st[c]) st[c] = true, tot++;
}
for(int j = 0; j <= w; j++)
{
if((w | j) == w) dp[j] = min(dp[j], a);
}
}
if(tot < n) cout << -1 << endl;
else {
int res = 0x3f3f3f3f;
for(int i = 0; i < (1 << n); i++)
for(int j = 0; j <= i; j++)
dp[i] = min(dp[i], dp[i ^ j] + dp[j]);
cout << dp[(1 << n) - 1] << endl;
}
return 0;
}

f

找一个环,记录并输出
我虽然过了,但是做法假了(
题目说的实际上是找一个最小环(环内无环)
但我只是找了一个环,然后只有一个样例的点没过
最后修改了一下加边的顺序过了,麻了。怎么写还没搞懂