ABC305
T1:Water Station
模拟
代码实现
// C++实现
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int ans = round(n/5.)*5;
cout << ans << '\n';
return 0;
}
// Python实现
n = int(input())
ans = int(round(n/5, 0))*5
print(ans)
T2:ABCDEFG
可以把边权挂在左边的点上,求一遍区间和即可
代码实现
#include <bits/stdc++.h>
using namespace std;
int main() {
char p, q;
cin >> p >> q;
vector<int> d = {3, 1, 4, 1, 5, 9};
if (p > q) swap(p, q);
p -= 'A'; q -= 'A';
int ans = 0;
for (int i = p; i < q; ++i) {
ans += d[i];
}
cout << ans << '\n';
return 0;
}
T3:Snuke the Cookie Picker
找出矩形所在的四个边界
代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
int li = h, lj = w, ri = 0, rj = 0;
rep(i, h)rep(j, w) {
if (s[i][j] == '#') {
li = min(li, i);
lj = min(lj, j);
ri = max(ri, i);
rj = max(rj, j);
}
}
for (int i = li; i <= ri; ++i) {
for (int j = lj; j <= rj; ++j) {
if (s[i][j] == '.') {
cout << i+1 << ' ' << j+1 << '\n';
}
}
}
return 0;
}