A
1024
B
1100325199.77
#include "bits/stdc++.h"
using namespace std;
constexpr double eps = 1E-3;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
double x = 0, y = 233333, ans = 0;
int dx = 15, dy = -17;
while (1) {
double t1 = (dx > 0 ? (343720. - x) / dx : x / -dx);
double t2 = (dy > 0 ? (233333. - y) / dy : y / -dy);
double t = min(t1, t2);
ans += sqrt(dx * t * dx * t + dy * t * dy * t);
x += dx * t;
y += dy * t;
if (t1 == t2) {
dx = -dx, dy = -dy;
} else if (t1 > t2) {
dy = -dy;
} else {
dx = -dx;
}
if (x < eps && abs(y - 233333.) < eps) {
break;
}
}
cout << fixed << setprecision(2) << ans << '\n';
return 0;
}
C
#include "bits/stdc++.h"
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int ans = 0;
for (int i = 1; i <= n; i++) {
string s = to_string(i);
reverse(s.begin(), s.end());
ans++;
for (int j = 0; j < (int)s.size(); j++) {
if (((s[j] - '0') & 1) == (j & 1)) {
ans--;
break;
}
}
}
cout << ans << '\n';
return 0;
}
D
#include "bits/stdc++.h"
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
string s;
cin >> n >> s;
reverse(s.begin(), s.end());
for (int i = 0; i < n; i++) {
int add = 0;
for (int j = 0; j < (int)s.size(); j++) {
if (s[j] != '.') {
int x = (s[j] - '0') * 2 + add;
s[j] = '0' + x % 10;
add = x / 10;
}
}
while (add > 0) {
s += '0' + add % 10;
add /= 10;
}
}
int add = 0;
for (int i = 0; i < (int)s.size(); i++) {
if (s[i] == '.') {
add = (s[i - 1] - '0' > 4); continue;
}
int x = s[i] - '0' + add;
s[i] = '0' + x % 10;
add = x / 10;
}
while (add > 0) {
s += '0' + add % 10;
add /= 10;
}
while (s.back() == '0') {
s.pop_back();
}
if (s.back() == '.') {
s += '0';
}
reverse(s.begin(), s.end());
for (int i = 0; i < (int)s.size() && s[i] != '.'; i++) {
cout << s[i];
}
return 0;
}
E
#include "bits/stdc++.h"
using namespace std;
constexpr int N = 2E5;
int c[N + 1];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
c[x]++;
}
for (int i = N; i >= 1; i--) {
int sum = 0;
for (int j = i; j <= N; j += i) {
sum += c[j];
}
if (sum > 2) {
sum = 3;
for (int j = i; j <= N && sum; j += i) {
for (int k = 0; k < c[j] && sum; k++) {
cout << j << ' '; sum--;
}
}
break;
}
}
return 0;
}
H
#include "bits/stdc++.h"
using namespace std;
using i64 = int64_t;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<i64> sum(n + 1);
for (int i = 0; i < n; i++) {
sum[i + 1] = sum[i] + a[i];
}
multiset<i64> s;
for (int l = 0; l < n; l++) {
for (int r = l + 1; r <= n; r++) {
s.insert(sum[r] - sum[l]);
}
}
i64 ans = 1E18;
for (int r = n; r > 0; r--) {
for (int l = 0; l < r; l++) {
s.erase(s.find(sum[r] - sum[l]));
}
for (int i = r; i <= n; i++) {
i64 v = sum[i] - sum[r - 1];
auto it = s.upper_bound(v);
if (it != s.end()) {
ans = min(ans, *it - v);
}
if (it != s.begin()) {
ans = min(ans, v - *prev(it));
}
}
}
cout << ans << '\n';
return 0;
}