Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <cmath>
- #include <iomanip>
- #define x first
- #define y second
- using namespace std;
- pair<int, int> input() {
- int x, y;
- cin >> x >> y;
- return make_pair(x, y);
- }
- pair<int, int> summ(pair<int, int> a, pair<int, int> b) {
- return make_pair(a.x + b.x, a.y + b.y);
- }
- pair<int, int> razn(pair<int, int> a, pair<int, int> b) {
- return make_pair(a.x - b.x, a.y - b.y);
- }
- int cross(pair<int, int> a, pair<int, int> b) {
- return a.x * b.y - a.y * b.x;
- }
- int scalar(pair<int, int> a, pair<int, int> b) {
- return a.x * b.x + a.y * b.y;
- }
- double len(pair<int, int> a, pair<int, int> b) {
- pair<int, int> n;
- n = make_pair(abs(a.x - b.x), abs(a.y - b.y));
- return sqrt(scalar(n, n));
- }
- pair<int, int> vect(pair<int, int> a, pair<int, int> b) {
- return make_pair(b.x - a.x, b.y - a.y);
- }
- int main() {
- pair<int, int> a, b, c, zero;
- double H;
- zero = make_pair(0, 0);
- a = input();
- b = input();
- c = input();
- int l;
- cin >> l;
- cout << fixed << setprecision(2);
- double A = len(a, c);
- double B = len(b, c);
- if(a == b){
- H = A;
- } else {
- H = abs(cross(vect(c, a), vect(c, b)) / len(a, b));
- }
- if(A <= B) {
- double k = scalar(vect(a, b), vect(a, c));
- cout << (k < 0? max(A - l, 0.0) : max(H - l, 0.0)) << endl;
- } else {
- double k = scalar(vect(b, a), vect(b, c));
- cout << (k < 0? max(B - l, 0.0) : max(H - l, 0.0)) << endl;
- }
- cout << max({A - l, B - l, 0.0});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement