2018-2019 ACM-ICPC, Asia Jiaozuo Regional Contest
https://codeforces.com/gym/102028
2020-12-11 --时间
-
A.
- 签到
const int maxn = 1e5 + 7; int t, n; char s[10][1000] = { "Typically Otaku", "Eye-opener", "Young Traveller", "Excellent Traveller", "Contemporary Xu Xiake"}; void solve() { cin >> t; while (t--) { int cnt = 0; for (int i = 1; i <= 4; i++) { cin >> n; if (n) cnt++; } cout << s[cnt] << endl; } }
- 签到
-
I.
- 贪心+前缀和
const int maxn = 1e5 + 7; int t, n; ll a[maxn], pre[maxn], sum; void solve() { cin >> t; while (t--) { cin >> n; pre[1] = 0; for (int i = 1; i < n; i++) cin >> a[i], pre[i] = a[i] + pre[i - 1]; ll lasum = 0, ad = 0; for (int k = 1; k <= n; k++) { if (k % 2 == 0) ad += pre[n - k / 2] - pre[k / 2 - 1]; lasum += ad; if (k != n) cout << lasum << " "; else cout << lasum << endl; } } }
- 贪心+前缀和
-
D.计算几何
- 相似三角,计算时避免使用 arctan,还有就是a > b 改成 a > b - esp
-
const int maxn = 1e5 + 7; int t, n; const long double pi = acos(-1); void solve() { cin >> t; while (t--) { long double a, b, r, d; cin >> a >> b >> r >> d; long double len = sqrt((r + a) * (r + a) + b * b); long double tand = acos((a + r) / len); d = d / 180 * pi; if (d >= tand || fabs(d - tand) < 1e-6) cout << fixed << setprecision(13) << len - r << endl; else { long double B = a + r, A = tan(d) * B, C = B / cos(d); long double c0 = b - A, a0 = c0 * sin(d); cout << fixed << setprecision(13) << a0 + C - r << endl; } } }
-
E.大数+素数
- 计算前60个素数组成所有集合的倒数和,推下公式打表写.不然会tle
- tle代码:
#include <bits/stdc++.h> #define ll long long using namespace std; #ifndef ONLINE_JUDGE clock_t prostart = clock(); #endif const int maxn = 1e4 + 7; struct Wint : vector<int> { Wint(int n = 0) { push_back(n); check(); } Wint &check() { while (!empty() && !back()) pop_back(); if (empty()) return *this; for (int i = 1; i < size(); ++i) { (*this)[i] += (*this)[i - 1] / 10; (*this)[i - 1] %= 10; } while