标签:ken task div typedef ace png 马拉松 clu its
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; ll a, b, c, d; void solve1() { if (a > 0) { puts("(-inf,inf)"); puts("-1"); } else { puts("-1"); puts("(-inf,inf)"); } } void solve2() { db x = -b / (a * 2.0); if (a > 0) { printf("(%.2f,inf)\n", x); printf("(-inf,%.2f)", x); } else { printf("(-inf,%.2f)\n", x); printf("(%.2f,inf)", x); } } void solve3() { a *= 3.0; b *= 2.0; ll delta = b * b - 4.0 * a * c; if (delta <= 0) { if (a > 0) { puts("(-inf,inf)"); puts("-1"); } else { puts("-1"); puts("(-inf,inf)"); } } else { db x1 = (-b - (db)sqrt(delta)) / (2.0 * a), x2 = (-b + (db)sqrt(delta)) / (2.0 * a); if (x1 > x2) swap(x1, x2); if (a > 0) { printf("(-inf,%.2f) (%.2f,inf)\n", x1, x2); printf("(%.2f,%.2f)", x1, x2); } else { printf("(%.2f,%.2f)\n", x1, x2); printf("(-inf,%.2f) (%.2f,inf)", x1, x2); } } } main() { //// freopen("3.in", "r", stdin); //// freopen("3.out", "w", stdout); ll task; scanf("%lld", &task); if (task == 1) return puts("-1"), puts("-1"), 0; else if (task == 2 || task == 3 || task == 4) scanf("%lld", &a), solve1(); else if (task == 5 || task == 6 || task == 7 || task == 8) scanf("%lld%lld", &a, &b), solve2(); else scanf("%lld%lld%lld", &a, &b, &c), solve3(); }
标签:ken task div typedef ace png 马拉松 clu its
原文地址:https://www.cnblogs.com/Chasing-Dreams-Z/p/14383395.html