2021牛客多校2

比赛情况在这里插入图片描述
在这里插入图片描述
过程:开场cqf签到D我签到C。然后wmd开I(并且成功成为全场除北大外第二个过掉I的 )。
然后开K,一起想了半小时左右cqf想到了正解,直接上。 然后…开始罚坐到比赛结束。本人甲级战犯,F推错公式坑惨队友。

TC Draw Grids

在这里插入图片描述
在这里插入图片描述
题意: 给定一个n*m的点阵,每次选两个相邻点连线
两个人轮流操作,不能连出封闭图形,不能操作者输。

idea: 不能连出封闭图形就是不能形成环,也就是图始终是一片森林
终态一定是一棵生成树,因此根据点数奇偶性即可判断

#include<iostream>
#include<cstdio>
#include<cstring>
#define LL long long
using namespace std;

int n,m;
int main()
{
	cin>>n>>m;
	if( n%2==0 || m%2==0 )
	{
		printf("YES");
	}
	else printf("NO");  	
	return 0;
}

TF Girlfriend

在这里插入图片描述
在这里插入图片描述

题意:空间内有6个点,满足〖|??〗_1 ??|≥??_1 |??_1 ??|,|??_2 ??|≥??_2 |??_2 ??|求??_1 〖,??〗_2 各自轨迹围成的空间体的体积交

idea:
在这里插入图片描述

#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>

using namespace std;

const double eps = 1e-4;
const double PI = acos(-1);

int T;

int main() {
    //freopen("test.in", "r", stdin);
    cin >> T;
    while(T--) {
        double a[3], b[3], c[3], d[3], k1, k2;
        cin >> a[0] >> a[1] >> a[2];
        cin >> b[0] >> b[1] >> b[2];
        cin >> c[0] >> c[1] >> c[2];
        cin >> d[0] >> d[1] >> d[2];
        cin >> k1 >> k2;

        double x1 = b[0] - (b[0] - a[0]) / (k1 + 1);
        double y1 = b[1] - (b[1] - a[1]) / (k1 + 1);
        double z1 = b[2] - (b[2] - a[2]) / (k1 + 1);

        double x2 = b[0] + ( (b[0] - a[0]) /  ( k1-1 ) );
        double y2 = b[1] + ( (b[1] - a[1]) /  ( k1-1 ) );
        double z2 = b[2] + ( (b[2] - a[2]) /  ( k1-1 ) );

        double r1 = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2)) * 0.5;

        double c1 = (x1 + x2) * 0.5;
        double c2 = (y1 + y2) * 0.5;
        double c3 = (z1 + z2) * 0.5;

        x1 = d[0] - (d[0] - c[0]) / (k2 + 1);
        y1 = d[1] - (d[1] - c[1]) / (k2 + 1);
        z1 = d[2] - (d[2] - c[2]) / (k2 + 1);

        x2 = d[0] + ( (d[0] - c[0]) /  ( k2-1 ) );
        y2 = d[1] + ( (d[1] - c[1]) /  ( k2-1 ) );
        z2 = d[2] + ( (d[2] - c[2]) /  ( k2-1 ) );

        double r2 = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2)) * 0.5;

        double t1 = (x1 + x2) * 0.5;
        double t2 = (y1 + y2) * 0.5;
        double t3 = (z1 + z2) * 0.5;
        double dis = sqrt((c1 - t1) * (c1 - t1) + (c2 - t2) * (c2 - t2) + (c3 - t3) * (c3 - t3));

        double alpha1 = (r1 * r1 + dis * dis - r2 * r2) / (2 * dis * r1);
        double h1 = r1 - r1 * alpha1;

        double alpha2 = (r2 * r2 + dis * dis - r1 * r1) / (2 * dis * r2);
        double h2 = r2 - r2 * alpha2;

        if(r2 > r1) swap(r1, r2), swap(h1, h2);
        double ans;
        if( dis - r1 - r2 >= eps ) ans = 0;
        else if(dis + r2 - r1 <= eps ) ans = 4.0 / 3.0 * PI * r2 * r2 * r2;
//        else if(dis - r1 <= eps && dis + r2 - r1 >= eps) ans = 4.0 / 3.0 * PI * r2 * r2 * r2- PI * h2 * h2 * (r2 - h2 / 3) + PI * h1 * h1 * (r1 - h1 / 3);
        else ans = PI * h1 * h1 * (r1 - h1 / 3) + PI * h2 * h2 * (r2 - h2 / 3);
        printf("%.5lf\n", ans);
    }

    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值