Xu Xiake in Henan Province
签到题。
直接看有几个数是非零。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
for(int i = 0; i < t; i ++)
{
int sum = 0;
for(int j = 0; j < 4; j ++)
{
int x;
cin >> x;
if(x != 0) sum ++;
}
if (sum == 0) cout << "Typically Otaku\n";
else if(sum == 1)
cout << "Eye-opener\n";
else if(sum == 2)
cout << "Young Traveller\n";
else if(sum == 3)
cout << "Excellent Traveller\n";
else
cout << "Contemporary Xu Xiake\n";
}
}
Distance
题目的意思就是每次从两边对称选择一个点,处理长度时要注意一下,时间卡的比较紧,所以用前缀和处理。
#include <bits/stdc++.h>
using namespace std;
long long int a[100100], sum[100100], ans[100100], num;
int main(int argc, char const *argv[]) {
int t, i, l, r, n;
while (scanf("%d", &t) != EOF) {
while (t--) {
scanf("%d", &n);
for (i = 1; i < n; i++) {
scanf("%lld", &a[i]);
sum[i] = sum[i - 1] + a[i];
}
num = 0;
l = 0;
r = n;
for (i = 1; i <= n; i++)
if (i % 2 == 0) {
r--;
ans[i] = ans[i - 1] + sum[r] - sum[l - 1] + num;
num = ans[i] - ans[i - 1];
} else {
l++;
ans[i] = ans[i - 1] + num;
}
for (i = 1; i < n; i++) printf("%lld ", ans[i]);
printf("%lld\n", ans[i]);
}
}
return 0;
}
Keiichi Tsuchiya the Drift King
几何题,找临界点,并且根据三角函数变换解决。
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
double a, b, r, d;
int T;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%lf%lf%lf%lf", &a, &b, &r, &d);
double maxx = sqrt((r + a) * (r + a) + b * b);
double dhu = d * PI / 180.0;
double x1 = acos((a + r) / maxx);
if ((dhu - x1) > 0) {
printf("%.12f\n", maxx - r);
} else {
double x2 = x1 - dhu;
double L = 2 * maxx * sin(x2 / 2);
double x3 = (PI - x2) / 2;
double p = L * cos(x3);
printf("%.12f\n", maxx - p - r);
}
}
return 0;
}