题解:P15016 [UOI 2020 II Stage] 考试
P15016 [UOI 2020 II Stage] 考试
solution
按题意模拟,分三类讨论答案。
::::info[当
即他答对了这道题,所以答案是
::::
::::info[当
他没有留空,答错了这道题,扣除
:::warning[注意]
他的分数不能低于
- 若
n - \frac{c}{4} \le 0 ,则输出0 。 - 若
n - \frac{c}{4} > 0 ,则输出n - \frac{c}{4} 。
:::
::::
::::info[当
做完了。
AC code
#include <bits/stdc++.h>
#define debug(a) cerr << (#a) << " = " << (a) << endl;
#define int long long
#define maxn 100010
#define endl '\n'
using namespace std;
int n, a, b, c;
int solve() {
if (a == b) {
return n + c;
}
if (a != 0 && a != b) {
if (n - c / 4 < 0) {
return 0;
}
else {
return n - c / 4;
}
}
if (a == 0) {
return n;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t; t = 1;
while (t--) {
cin >> n >> a >> b >> c;
cout << solve() << endl;
}
return 0;
}