Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
60338 | yangkangrui | S1 | C++ | 通过 | 100 | 115 MS | 260 KB | 2088 | 2022-10-15 11:26:13 |
#include <iostream> #include <cstdio> #include <cmath> using namespace std; int t; int read() { int x=0,f=1; char c=getchar(); while(!(c>='0'&&c<='9')) {if(c=='-')f=-f;c=getchar();} while(c>='0'&&c<='9') {x=x*10+c-48;c=getchar();} return x*f; } struct node { int x, y; node() { x = y = 0;} node(int _x, int _y) { x = _x; y = _y;} } p1, p2, p3; int r; double ppow(double x, double y) { return x * x; } double calc_dis() { double k = (p2.y - p1.y)/(double)(p2.x - p1.x); double b = p1.y - p1.x * k; double kp = -1 / k; double bp = p3.y - kp * p3.x; double x = (bp - b) / (k - kp); double y = k * x + b; return sqrt(ppow(y - p3.y, 2) + ppow(x - p3.x, 2)); } double pdis(node a, node b) { return sqrt(ppow(a.x - b.x, 2) + ppow(a.y - b.y, 2)); } void ch1() { double dis1 = calc_dis(); // printf("%.2lf\n", dis1); double dis2 = max(pdis(p1, p3), pdis(p2, p3)); printf("%.2lf %.2lf\n", dis1, dis2); } void ch2() { double dis1 = calc_dis() - r; // printf("%.2lf\n", dis1); double dis2 = max(pdis(p1, p3), pdis(p2, p3)) + r; printf("%.2lf %.2lf\n", dis1, dis2); } int main() { // freopen("S1.in", "r", stdin); // freopen("S1.out", "w", stdout); t = read(); while (t--) { p1.x = read(); p1.y = read(); p2.x = read(); p2.y = read(); p3.x = read(); p3.y = read(); r = read(); if (p1.y == p2.y) { printf("%.2lf %.2lf\n", fabs(p3.y - p1.y) - r, sqrt(max(ppow(p3.x - p2.x, 2), ppow(p3.x - p1.x, 2)) + ppow(p3.y - p1.y, 2)) + r); continue; } else if (p1.x == p2.x) { printf("%.2lf %.2lf\n", fabs(p3.x - p1.x) - r, sqrt(max(ppow(p3.y - p1.y, 2), ppow(p3.y - p2.y, 2)) + ppow(p3.x - p1.x, 2)) + r); continue; } else if (r == 0) { ch1(); continue; } else { ch2(); continue; } } return 0; }