Link Problem: https://open.kattis.com/problems/amsterdamdistance
Submission 9126857
ID | DATE | PROBLEM | STATUS | CPU | LANG | TEST CASES |
---|---|---|---|---|---|---|
9126857 | 17:21:38 | Amsterdam Distance | Accepted | 0.00 s | C++ | 33/33 |
Files submitted
#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:
Post a Comment