Translate

Views

Monday, July 11, 2022

Solution Kattis - Amsterdam Distance

 

Link Problem: https://open.kattis.com/problems/amsterdamdistance


Submission 9126857

IDDATEPROBLEMSTATUSCPULANGTEST CASES
912685717:21:38Amsterdam Distance
Accepted
0.00 sC++
33/33


Files submitted

amsterdamdistance.cpp

#include<bits/stdc++.h>
#define M_PI 3.1415926
using namespace std;
int main(){
int nx, ny, x1, y1, x2, y2;
double r;
cin >> nx >> ny >> r >> x1 >> y1 >> x2 >> y2;
double res= DBL_MAX;
for(int y= 0; y<= min(y1, y2); y++){
double dy= r / ny;
double dy1= dy * (y1-y);
double dy2= dy * (y2-y);
double rr= r / ny * y;
double dx= rr*M_PI / nx;
double dx12= dx * abs(x1-x2);
res= min(res, dy1 + dy2 + dx12);
}
cout<<fixed<<setprecision(7)<<res;
}

No comments: