牛客暑期多校训练营10
发表于:2023-08-19 | 分类: 思维
字数统计: 509 | 阅读时长: 2分钟 | 阅读量:

更新至K,M…
robocom只做了个签到,烂!开摆!

题K

题意:没看懂, 给定 n,m(1n,m20)n, m(1\le n,m \le 20)

解:直接求 (2/n)m(2/n)^m

1
2
3
4
5
6
7
8
9
10
11
12
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int main(){
int n, m; cin >> n >> m;
double x = 2.0 / n, ans = 1;
if(n != 1)
for(int i = 1; i <= m; ++ i) ans *= x;

printf("%.15lf", ans);
}

题M

题意:给定一个式子 a+b=ca+b=c,不知道这个式子是否成立,问是否能插入一个 digitdigit 使得等式成立。

解:因为 1a,b,c1e61\le a,b,c \le 1e6, 每个数模拟插入 090-9

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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int get(string s){
int ans = 0;
for(int i = 0; i < s.size(); ++ i){
int x = s[i] - '0';
ans = ans * 10 + x;
}
return ans;
}
int main(){
string a, b, c, x1, x2; cin >> a >> x1 >> b >> x2 >> c;
int aa = get(a), bb = get(b), cc = get(c);
for(int i = 0; i <= a.size(); ++ i){
for(char j = '0'; j <= '9'; ++ j){
string s = a.substr(0, i) + j + a.substr(i);
int k = get(s);
if(k + bb == cc){
cout << "Yes\n" << k << " + " << bb << " = " << cc << '\n';
return 0;
}
}
}
for(int i = 0; i <= b.size(); ++ i){
for(char j = '0'; j <= '9'; ++ j){
string s = b.substr(0, i) + j + b.substr(i);
int k = get(s);
if(k + aa == cc){
cout << "Yes\n" << aa << " + " << k << " = " << cc << '\n';
return 0;
}
}
}
for(int i = 0; i <= c.size(); ++ i){
for(char j = '0'; j <= '9'; ++ j){
string s = c.substr(0, i) + j + c.substr(i);
int k = get(s);
if(aa + bb == k){
cout << "Yes\n" << aa << " + " << bb << " = " << k << '\n';
return 0;
}
}
}
cout << "No";
}
上一篇:
牛客暑期多校训练营9
下一篇:
牛客暑期多校训练营8