結果

問題 No.1319 最強とんがりコーン
ユーザー 👑 hos.lyrichos.lyric
提出日時 2020-12-16 00:05:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 3,438 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 99,224 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 07:04:55
合計ジャッジ時間 8,745 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
4,348 KB
testcase_01 AC 104 ms
4,348 KB
testcase_02 AC 71 ms
4,348 KB
testcase_03 AC 53 ms
4,348 KB
testcase_04 AC 108 ms
4,348 KB
testcase_05 AC 93 ms
4,348 KB
testcase_06 AC 75 ms
4,348 KB
testcase_07 AC 56 ms
4,348 KB
testcase_08 AC 77 ms
4,348 KB
testcase_09 AC 98 ms
4,348 KB
testcase_10 AC 38 ms
4,348 KB
testcase_11 AC 59 ms
4,348 KB
testcase_12 AC 81 ms
4,348 KB
testcase_13 AC 63 ms
4,348 KB
testcase_14 AC 43 ms
4,348 KB
testcase_15 AC 66 ms
4,348 KB
testcase_16 AC 45 ms
4,348 KB
testcase_17 AC 105 ms
4,348 KB
testcase_18 AC 48 ms
4,348 KB
testcase_19 AC 107 ms
4,348 KB
testcase_20 AC 105 ms
4,348 KB
testcase_21 AC 104 ms
4,348 KB
testcase_22 AC 104 ms
4,348 KB
testcase_23 AC 104 ms
4,348 KB
testcase_24 AC 104 ms
4,348 KB
testcase_25 AC 105 ms
4,348 KB
testcase_26 AC 104 ms
4,348 KB
testcase_27 AC 104 ms
4,348 KB
testcase_28 AC 104 ms
4,348 KB
testcase_29 AC 104 ms
4,348 KB
testcase_30 AC 105 ms
4,348 KB
testcase_31 AC 104 ms
4,348 KB
testcase_32 AC 74 ms
4,348 KB
testcase_33 AC 109 ms
4,348 KB
testcase_34 AC 104 ms
4,348 KB
testcase_35 AC 105 ms
4,348 KB
testcase_36 AC 105 ms
4,348 KB
testcase_37 AC 104 ms
4,348 KB
testcase_38 AC 104 ms
4,348 KB
testcase_39 AC 106 ms
4,348 KB
testcase_40 AC 61 ms
4,348 KB
testcase_41 AC 37 ms
4,348 KB
testcase_42 AC 41 ms
4,348 KB
testcase_43 AC 39 ms
4,348 KB
testcase_44 AC 42 ms
4,348 KB
testcase_45 AC 36 ms
4,348 KB
testcase_46 AC 91 ms
4,348 KB
testcase_47 AC 39 ms
4,348 KB
testcase_48 AC 60 ms
4,348 KB
testcase_49 AC 40 ms
4,348 KB
testcase_50 AC 38 ms
4,348 KB
testcase_51 AC 37 ms
4,348 KB
testcase_52 AC 39 ms
4,348 KB
testcase_53 AC 36 ms
4,348 KB
testcase_54 AC 45 ms
4,348 KB
testcase_55 AC 42 ms
4,348 KB
testcase_56 AC 38 ms
4,348 KB
testcase_57 AC 37 ms
4,348 KB
testcase_58 AC 36 ms
4,348 KB
testcase_59 AC 36 ms
4,348 KB
testcase_60 AC 35 ms
4,348 KB
testcase_61 AC 34 ms
4,348 KB
testcase_62 AC 35 ms
4,348 KB
testcase_63 AC 34 ms
4,348 KB
testcase_64 AC 76 ms
4,348 KB
testcase_65 AC 77 ms
4,348 KB
testcase_66 AC 34 ms
4,348 KB
testcase_67 AC 104 ms
4,348 KB
testcase_68 AC 101 ms
4,348 KB
testcase_69 AC 104 ms
4,348 KB
testcase_70 AC 40 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0