Acwing第 61 场周赛【完结】

https://www.acwing.com/activity/content/competition/problem_list/2079/
T3,向量知识点有点忘了。

4497. 分糖果

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
int main(void)
{
    
    
    LL t,a,b,c; cin>>t;
    while(t--)
    {
    
    
        cin>>a>>b>>c;
        cout<<(a+b+c)/2<<'\n';
    }
    return 0;
}

4498. 指针【二进制枚举】

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int N=25;
int a[N],n,flag; 
int main(void)
{
    
    
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<(1<<n);i++)
	{
    
    
		int sum=0;
		for(int j=0;j<n;j++) 
		{
    
    
			if(i>>j&1) sum=(sum+a[j])%360;
			else sum=(sum-a[j]+360)%360;
		}
		if(!sum) flag=1;
	}
	if(flag) puts("YES");
	else puts("NO");
    return 0;
}

4499. 画圆【计算几何】

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
const double eps=1e-8;
int cmp(double x, double y)
{
    
    
    if (fabs(x - y) < eps) return 0;
    if (x < y) return -1;
    return 1;
}
int main(void)
{
    
    
    double r,x,y,x1,y1;
    cin>>r>>x>>y>>x1>>y1;
    double dx=x1-x;
    double dy=y1-y;
    double d=sqrt(dx*dx+dy*dy);
    if(cmp(d,r)>=0) printf("%.6lf %.6lf %.6lf",x,y,r);
    else 
    {
    
    
        if(!cmp(x,x1)&&!cmp(y,y1)) printf("%.6lf %.6lf %.6lf",x+r/2,y,r/2);
        else
        {
    
    
            double len=(r+d)/2;
            double ans1=x1+(x-x1)/d*len;
            double ans2=y1+(y-y1)/d*len;
            printf("%.6lf %.6lf %.6lf",ans1,ans2,len);
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_46527915/article/details/125966269