2021-1-30组队赛补题

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;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值