qbxt十一系列三

【题目分析】

 这完全是个数学题啊,有些崩溃,上午考试写了两个小时,20分,于是乎 下午改啊改啊 改到10分....如果第二个圆的圆心在第一个圆.....呃 说不清楚 像下面这个图这样,两圆重叠部分中C2对应的扇形对应的圆心角(有些绕)是超过180的,所以我们先算这个角的一半再乘以2防止出现负数,然后求三角形面积的时候不要用海伦公式,如果你想用考虑考虑后果(还是会出现负数hh),好了这样我的AC道路就走了一半了,可以60(真相还在后面)。我是多么迫切的想要AC,于是乎开始找错误找错误....发现在判断两圆包含关系的时候没有sqrt!!!好,我们加上,继续评测,然而还是没有AC!!!好吧,在两个圆包含的情况中(就是第二个if那里)圆心间的距离是小于r1+r2 而不是小于等于!在我以为能A掉的时候,意外又出现了,查错查了半个小时发现少了个括号,累瘫

总结:细节!细节!细节!

 

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const double pi=3.1415926535898;
int t;
double x1,y,r1,x2,y2,r2,s,a,b,c,k,m,w,p;
int main()
{
    freopen("standing.in","r",stdin);
    freopen("standing.out","w",stdout);
    scanf("%d",&t);
    while(t--){
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y,&r1,&x2,&y2,&r2);
        if(sqrt((x2-x1)*(x2-x1)+(y2-y)*(y2-y))>=(r1+r2))
            s=pi*r1*r1+pi*r2*r2;
        else if(sqrt((x2-x1)*(x2-x1)+(y2-y)*(y2-y))<abs(r1-r2))//here
            s=max(pi*r1*r1,pi*r2*r2);
        else
        {
            s=r1*r1*pi+pi*r2*r2;
            k=sqrt((x1-x2)*(x1-x2)+(y-y2)*(y-y2));
            
            w=(r1*r1+k*k-r2*r2)/(2*r1*k);
            p=2*acos(w);//圆心角的度数 
            s-=((p*r1*r1)/2-sin(p)*r1*r1/2);//总面积-(扇形-三角形)
            
            w=(r2*r2+k*k-r1*r1)/(2*r2*k);
            p=2*acos(w);
            s-=((p*r2*r2)/2-sin(p)*r2*r2/2);
        }
        printf("%.3lf
",s);
    }
    fclose(stdin);fclose(stdout);
    return 0;
}

 

3

 

【题目分析】

    水题

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define maxn 100010
int n,k,cnt;
struct node{
    int f,t,p;
}num[maxn];
int main()
{
    freopen("resist.in","r",stdin);
    freopen("resist.out","w",stdout);
    scanf("%d%d",&n,&k);
    num[1].f=n;num[1].t=2;
    num[n].f=n-1;num[n].t=1;
    for(int i=2;i<n;i++)
        num[i].f=i-1,num[i].t=i+1;
    int x=1;
    while(x!=num[x].f&&x!=num[x].t)
    {
        cnt++;
        if(cnt==k)
        {
            num[num[x].f].t=num[x].t;
            num[num[x].t].f=num[x].f;
            cnt=0;
        }
        x=num[x].t;
    }
    printf("%d",x);
    fclose(stdin);fclose(stdout);
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<iostream>
#define MAXN 1005
using namespace std;
int n,m,maxn,minn;
int t1[MAXN],t2[MAXN];
bool fill1[MAXN],fill2[MAXN];
int main ()
{
    freopen ("neighbor.in","r",stdin);
    freopen ("neighbor.out","w",stdout);
    scanf ("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
            scanf ("%d",&t1[i]);
    for (int i=1;i<=m;i++)
            scanf ("%d",&t2[i]);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
        {
            maxn+=min(t1[i],t2[j]);
            if (t1[i]==t2[j]&&!fill1[i]&&!fill2[j])
            {
                minn+=t1[i];
                fill1[i]=true;
                fill2[j]=true;
            }
        }
    for (int i=1;i<=n;i++)
        if (!fill1[i])
            minn+=t1[i];
    for (int i=1;i<=m;i++)
        if (!fill2[i])
            minn+=t2[i];
    printf ("%d %d",minn,maxn);
    return 0;
}
原文地址:https://www.cnblogs.com/xiaoningmeng/p/5932532.html