bmeonline Contest1003 做题记录
A

明显强度上来了啊。
直接全化成分钟做,然后把计算结果转化成小时和分钟即可。
点击查看代码
//24 * 60 = 1440
#include <bits/stdc++.h>
using namespace std;
namespace steven24 {
int d[3], h[3], m[3], sum[3];
int ans;
void main() {
for (int i = 1; i <= 2; ++i) {
cin >> d[i] >> h[i] >> m[i];
sum[i] = d[i] * 1440 + h[i] * 60 + m[i];
}
ans = sum[2] - sum[1];
cout << ans / 60 << " " << ans % 60 << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
steven24::main();
return 0;
}
/*
1 22 7 2 9 52
*/
B

switch 教学局,记得写 break;
点击查看代码
#include <bits/stdc++.h>
using namespace std;
namespace steven24 {
void main() {
int x;
cin >> x;
switch(x) {
case 1 : cout << "Monday\n"; break;
case 2 : cout << "Tuesday"; break;
case 3 : cout << "Wednesday"; break;
case 4 : cout << "Thursday"; break;
case 5 : cout << "Friday"; break;
case 6 : cout << "Saturday"; break;
case 0 : cout << "Sunday"; break;
default : cout << "Bad"; break;
}
}
}
int main() {
ios::sync_with_stdio(false);
steven24::main();
return 0;
}
/*
5
*/
C

明显三点共线更简单嘛。
点击查看代码
#include <bits/stdc++.h>
#define db double
using namespace std;
namespace steven24 {
db x[4], y[4];
void main() {
for (int i = 1; i <= 3; ++i) cin >> x[i] >> y[i];
if ((x[1] - x[2]) * (y[1] - y[3]) == (x[1] - x[3]) * (y[1] - y[2])) cout << "BAD\n";
else cout << "OK\n";
}
}
int main() {
ios::sync_with_stdio(false);
steven24::main();
return 0;
}
/*
0 0 0 1 1 0
*/
D

直接两两判断即可。
点击查看代码
#include <bits/stdc++.h>
using namespace std;
namespace steven24 {
void main() {
int x, y, z;
cin >> x >> y >> z;
if (x == y) cout << "C";
else if (x == z) cout << "B";
else cout << "A";
}
}
int main() {
ios::sync_with_stdio(false);
steven24::main();
return 0;
}
/*
1 1 2
*/
E

提供一种时间复杂度很高但是很省脑子的做法:先把 \(4000\) 年以内的闰年全部筛出来(猜测不会给更大的数据),然后两头找即可。
点击查看代码
#include <bits/stdc++.h>
using namespace std;
namespace steven24 {
bool r[4001];
int n;
bool judge(int yy) {
if (!(yy % 100)) {
if (yy % 400) return 0;
else return 1;
} else {
if (yy % 4) return 0;
else return 1;
}
}
void main() {
for (int i = 1; i <= 4000; ++i) r[i] = judge(i);
cin >> n;
int eps = 0;
while (1) {
if (r[n - eps]) {
cout << n - eps << " ";
if (r[n + eps] && eps) cout << n + eps << "\n";
break;
}
if (r[n + eps]) {
cout << n + eps << "\n";
break;
}
++eps;
}
}
}
int main() {
ios::sync_with_stdio(false);
steven24::main();
return 0;
}
/*
2017
*/
F

麻烦,就是麻烦。
注意先将月收入换算成年收入。
点击查看代码
#include <bits/stdc++.h>
#define db double
using namespace std;
namespace steven24 {
int n;
db ans;
void calc() {
n *= 12;
n -= 60000;
ans += min(36000, n) * 0.03;
if (n > 36000) ans += min(144000 - 36000, n - 36000) * 0.1;
if (n > 144000) ans += min(300000 - 144000, n - 144000) * 0.2;
if (n > 300000) ans += min(420000 - 300000, n - 300000) * 0.25;
if (n > 420000) ans += min(660000 - 420000, n - 420000) * 0.3;
if (n > 660000) ans += min(960000 - 660000, n - 660000) * 0.35;
ans += max(0, n - 960000) * 0.45;
}
void main() {
cin >> n;
calc();
cout << ans << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
steven24::main();
return 0;
}
/*
8000
*/

浙公网安备 33010602011771号