【YACS 2021 年 5 月月赛 丙组】植树造林

Leo2011 大气压强

题目 Link


考虑到老师不能砍树,所以最少补种树就是把剩下那二位的种树数补成最多的那位。

这里介绍个小语法:

1
2
max({a, b, c});
max(max(a, b), c);

两行代码都是在求 的最大值,但是第二个是两两求,第一个是整体求,稍微方便一点。


ACCode:

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
/*Code by Leo2011*/
#include <bits/stdc++.h>

#define log printf
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define FOR(i, l, r) for (int(i) = (l); (i) <= (r); ++(i))
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(nullptr); \
cout.tie(nullptr);

using namespace std;

typedef __int128 i128;
typedef long long ll;
typedef pair<int, int> PII;

int a, b, c;

template <typename T>

inline T read() {
T sum = 0, fl = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') fl = -1;
for (; isdigit(ch); ch = getchar()) sum = sum * 10 + ch - '0';
return sum * fl;
}

template <typename T>

inline void write(T x) {
if (x < 0) {
putchar('-'), write<T>(-x);
return;
}
static T sta[35];
int top = 0;
do { sta[top++] = x % 10, x /= 10; } while (x);
while (top) putchar(sta[--top] + 48);
}

int main() {
a = read<int>(), b = read<int>(), c = read<int>();
write<int>(3 * max({a, b, c}) - (a + b + c));
return 0;
}

AC 记录~

  • 标题: 【YACS 2021 年 5 月月赛 丙组】植树造林
  • 作者: Leo2011
  • 创建于 : 2024-06-27 20:25:33
  • 更新于 : 2024-08-29 16:37:51
  • 链接: https://leo2011.eu.org/2024/06/27/yacs-2021-nian-5-yue-yue-sai-bing-zu-zhi-shu-zao-lin/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
【YACS 2021 年 5 月月赛 丙组】植树造林