⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2722.cpp

📁 北京大学ACM题 Here is a geometric problem. You have an angle and some squares in the first quadrant of
💻 CPP
字号:
#include"stdio.h"
#include"string.h"
#include"math.h"

int main()
{
    int N;
    double x1,y1,x2,y2;
    double d1,d2,d3;
    double l1,l2;
    double a[15];
    double s,s1;
    int i,j;
    scanf("%d",&N);
    while(N!=0){
       l1=0;
       l2=0;
       s1=0;
       scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
       for(i=0;i<N;i++)
          scanf("%lf",&a[i]);
       for(i=0;i<N;i++) {l1+=a[i]; s1+=a[i]*a[i]*0.5;}
       l1=l1*sqrt(2);
       if(y1/x1==y2/x2) {printf("0\n"); scanf("%d",&N); continue;}
       if(y1/x1>y2/x2){
           d1=atan(y1/x1)-atan(y2/x2);
           d2=3.14159265*0.25+atan(x1/y1);
           d3=3.14159265*0.25+atan(y2/x2);
           l2=l1*sin(d2)/sin(d1);
           s=0.5*l1*l2*sin(d3);
           printf("%.3lf\n",s-s1);
       }
       else {
          d1=atan(y2/x2)-atan(y1/x1);
          d3=3.14159265*0.25+atan(y1/x1);
          d2=3.14159265*0.25+atan(x2/y2);
          l2=l1*sin(d2)/sin(d1);
          s=0.5*l1*l2*sin(d3);
          printf("%.3lf\n",s-s1);
       }
       scanf("%d",&N);
    }
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -