-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path2073.cpp
70 lines (66 loc) · 1.03 KB
/
2073.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
int N,x1,y1,x2,y2,t,s;
double sum;
while(scanf("%d",&N)!=EOF)
{
while(N--)
{
sum=0;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
if(x1==x2&&y1==y2)
{
printf("%.3f\n",sum); //Êä³ö 0
break;
}
if(x1+y1>x2+y2)
{
swap(x1,x2);
swap(y1,y2);
}
else if(x1+x2==x2+y2)
{
if(x1>x2)
{
swap(x1,x2);
swap(y1,y2);
}
}
//Ä£Äâ
while(1)
{
if(y1==0)
{
sum=sum+sqrt((x1*x1)+(x1+1)*(x1+1));
y1=x1+1;
x1=0;
}
else
{
sum=sum+sqrt(2);
x1++;
y1--;
}
//µ½´ïÖÕµã
if(x1==x2&&y1==y2)
break;
}
printf("%.3f\n",sum);
}
}
return 0;
}