UVA 11314 - Hardly Hard(数论)
2014-04-27 11:25
232 查看
题目链接:11314 - Hardly Hard
题意:给定A,B两点,求Y轴上一点C和X轴上一点D,使得该四边形周长最小。思路:B以Y轴做对称点,A以X轴做对称点,然后两点相连就是其他三边的周长,因为两点间线段最短,然后再加上AB长度即可
代码:
#include <stdio.h> #include <string.h> #include <math.h> int t; struct Point { double x, y; Point() {} Point(double _x, double _y) { x = _x; y = _y; } void scan() { scanf("%lf%lf", &x, &y); } } a, b, c, d; double dis(Point a, Point b) { double x = a.x - b.x; double y = a.y - b.y; return sqrt(x * x + y * y); } int main() { scanf("%d", &t); while (t--) { a.scan(); b.scan(); c = Point(-b.x, b.y); d = Point(a.x, -a.y); printf("%.3lf\n", dis(a, b) + dis(c, d)); } return 0; }
相关文章推荐
- uva 11314 - Hardly Hard(坐标系问题)
- poj 1606 Jugs and poj 3414 Pots(数组模拟BFS) uva 571 (数论)
- UVA 10951 - Polynomial GCD []【数论】
- 【数论-数位统计】UVa 11076 - Add Again
- 【数论】UVa 10586 - Polynomial Remains
- 紫书搜索 习题7-7 UVA - 12558 Egyptian Fractions (HARD version) IDA*迭代加深搜索
- UVa 11526 H(n) (数论)
- uva 1315 - Crazy tea party(数论)
- UVA 11609 - Teams(数论+推理+快速幂)
- UVA 12716 GCD XOR (数论,规律)
- uva11538(数论)
- uva 10995 - Educational Journey(数论)
- UVA 10791 - Minimum Sum LCM(数论)
- UVA_live 7720 思考 数论 快速幂取模
- uva 1388 - Graveyard(数论)
- uva 10006 数论入门题
- UVA10006 Carmichael Numbers(数论)
- UVA 11916 - Emoogle Grid(数论)
- uva 11014 - Make a Crystal(数论)
- UVA 10555 - Dead Fraction(数论+无限循环小数)