[NYOJ] [acm-164] Distance Between Two Points

Problem Description

Loading...

Problem Analysis

Actually it’s the same as that problem on HDU
But I’ve figured it out
No need to overthink it
Upload it if you want to
Just do whatever I feel like ╭(╯^╰)╮

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include<stdio.h>
#include<math.h>
int main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		double x1,y1,x2,y2;
		scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
		printf("%.2lf\n",sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
	}
	return 0;
}

Haven’t come up with anything impressive for the reference solution either
But let’s just take it as another chance to admire C++

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main() {
	/*freopen("1.txt","r",stdin);
	freopen("2.txt","w",stdout);*/

	double x1,x2,y1,y2,m;
	double a;
	cin>>m;
	while(m--) {
		cin>>x1>>y1>>x2>>y2;
		a=sqrt((double)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
		cout.setf(ios::fixed);
		cout<<setprecision(2)<<a<<endl;
	}
	return 0;
}

Problem address:Problem Details - Distance Between Two Points - NYOJ

Loading...