zoukankan      html  css  js  c++  java
  • 杭电2073

     1 #include<stdio.h>
     2 #include<math.h>
     3 int main()
     4 {
     5     int n,i,t;
     6     double x1,y1,x2,y2,s;
     7     while(~scanf("%d",&n))
     8     {
     9         while(n--)
    10         {
    11             scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    12             if(x2+y2 < x1+y1)
    13             {
    14                 t=x1;
    15                 x1=x2;
    16                 x2=t;
    17                 t=y1;
    18                 y1=y2;
    19                 y2=t;
    20             }
    21             t=0;
    22             if(x1)
    23             {
    24                 y1+=x1;
    25                 t-=x1;
    26                 x1=0;
    27             }
    28             if(y2)
    29             {
    30                 x2+=y2;
    31                 t-=y2;
    32                 y2=0;
    33             }
    34             for(i=y1,s=0; i<x2; ++i)
    35                 s+=sqrt(i*i+(i+1)*(i+1));
    36             for(i=y1; i<=x2; ++i)
    37                 t+=i;
    38             s+=t*sqrt(2);
    39             printf("%.3lf
    ",s);
    40         }
    41     }
    42 }
     1 #include<stdio.h>
     2 #include<math.h>
     3 int main()
     4 {
     5     int n,i,t;
     6     double x1,y1,x2,y2,s;
     7     while(~scanf("%d",&n))
     8     {
     9         while(n--)
    10         {
    11             scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    12             if(x2+y2 < x1+y1)
    13             {
    14                 t=x1;
    15                 x1=x2;
    16                 x2=t;
    17                 t=y1;
    18                 y1=y2;
    19                 y2=t;
    20             }
    21             t=0;
    22             if(x1)
    23             {
    24                 y1+=x1;
    25                 t-=x1;
    26                 x1=0;
    27             }
    28             if(y2)
    29             {
    30                 x2+=y2;
    31                 t-=y2;
    32                 y2=0;
    33             }
    34             for(i=y1,s=0; i<x2; ++i)
    35                 s+=sqrt(i*i+(i+1)*(i+1));
    36             for(i=y1; i<=x2; ++i)
    37                 t+=i;
    38             s+=t*sqrt(2);
    39             printf("%.3lf
    ",s);
    40         }
    41     }
    42 }
  • 相关阅读:
    Python--魔法方法
    Flask之request实现思想
    关于python一切皆对象的理解
    python快速生成依赖包
    redis的安装和使用
    linux-环境变量的配置
    python-虚拟环境的配置
    11-Linux-系统服务
    10-Linux-进程管理
    [SCOI2014]方伯伯的玉米田
  • 原文地址:https://www.cnblogs.com/qq188380780/p/6087371.html
Copyright © 2011-2022 走看看