#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main() {
vector<vector<double>> ans(201, vector<double>(201, 0));
double q = sqrt(2.0);
for (int i = 1; i <= 200; i++) {
ans[0][i] = sqrt((double)i * i + (i - 1) * (i - 1)) + ans[i - 1][0];
for (int x = 1, y = i - 1; y >= 0; x++, y--) {
ans[x][y] = ans[x - 1][y + 1] + q;
}
}
int n;
cin >> n;
while (n--) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
/* cout << ans[x1][y1] << endl; */
/* cout << ans[x2][y2] << endl; */
printf("%.3f\n", abs(ans[x1][y1] - ans[x2][y2]));
}
return 0;
};
杭电OJ 2073 无限的路 C++
最新推荐文章于 2024-05-09 21:35:25 发布