結果
問題 | No.1319 最強とんがりコーン |
ユーザー |
👑 |
提出日時 | 2020-12-16 00:05:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 3,438 bytes |
コンパイル時間 | 854 ms |
コンパイル使用メモリ | 98,928 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-20 02:35:55 |
合計ジャッジ時間 | 7,548 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 70 |
ソースコード
#include <cassert>#include <cmath>#include <cstdint>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>#include <bitset>#include <complex>#include <deque>#include <functional>#include <iostream>#include <map>#include <numeric>#include <queue>#include <set>#include <sstream>#include <string>#include <unordered_map>#include <unordered_set>#include <utility>#include <vector>using namespace std;using Int = long long;template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }using Double = long double;struct Pt {Double x, y;Pt() {}Pt(Double x, Double y) : x(x), y(y) {}Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }Pt operator/(const Pt &a) const { const Double d2 = a.abs2(); return Pt((x * a.x + y * a.y) / d2, (y * a.x - x * a.y) / d2); }Pt operator+() const { return Pt(+x, +y); }Pt operator-() const { return Pt(-x, -y); }Pt operator*(const Double &k) const { return Pt(x * k, y * k); }Pt operator/(const Double &k) const { return Pt(x / k, y / k); }friend Pt operator*(const Double &k, const Pt &a) { return Pt(k * a.x, k * a.y); }Pt &operator+=(const Pt &a) { x += a.x; y += a.y; return *this; }Pt &operator-=(const Pt &a) { x -= a.x; y -= a.y; return *this; }Pt &operator*=(const Pt &a) { return *this = *this * a; }Pt &operator/=(const Pt &a) { return *this = *this / a; }Pt &operator*=(const Double &k) { x *= k; y *= k; return *this; }Pt &operator/=(const Double &k) { x /= k; y /= k; return *this; }Double abs() const { return sqrt(x * x + y * y); }Double abs2() const { return x * x + y * y; }Double arg() const { return atan2(y, x); }Double dot(const Pt &a) const { return x * a.x + y * a.y; }Double det(const Pt &a) const { return x * a.y - y * a.x; }friend ostream &operator<<(ostream &os, const Pt &a) { os << "(" << a.x << ", " << a.y << ")"; return os; }};const Double EPS = 1e-10;const Double INF = 1e+10;const Double PI = acos(-1.0);inline int sig(Double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }inline Double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }double aCC(Pt a, double r, Pt b, double s) {double d = (a - b).abs();if (sig(r - s - d) >= 0) return s * s * PI;if (sig(s - r - d) >= 0) return r * r * PI;if (sig(r + s - d) <= 0) return 0;double x = (d * d + r * r - s * s) / (d * 2);double h = sqrt(r * r - x * x);return r * r * atan2(h, x) + s * s * atan2(h, d - x) - d * h;}constexpr int N = 1'000'000;Double R, H, D;int main() {for (; ~scanf("%Lf%Lf%LF", &R, &H, &D); ) {Double ans = 0.0L;for (int i = 0; i <= N; ++i) {const Double r = R / N * i;const Double res = aCC(Pt(0.0L, 0.0L), r, Pt(D, 0.0L), r);ans += ((i == 0 || i == N) ? 1 : (i % 2 == 0) ? 2 : 4) * res;}ans *= (H / N) / 3.0L;printf("%.12Lf\n", ans);}return 0;}