码迷,mamicode.com
首页 > 其他好文 > 详细

杭电2073

时间:2016-11-22 01:37:24      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:div   log   scan   for   bsp   mat   double   ++   while   

 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\n",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\n",s);
40         }
41     }
42 }

 

杭电2073

标签:div   log   scan   for   bsp   mat   double   ++   while   

原文地址:http://www.cnblogs.com/qq188380780/p/6087371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!