結果
| 問題 | 
                            No.1319 最強とんがりコーン
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tmaehara
                         | 
                    
| 提出日時 | 2022-01-03 04:58:07 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 1,510 bytes | 
| コンパイル時間 | 1,833 ms | 
| コンパイル使用メモリ | 74,880 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-12 11:38:55 | 
| 合計ジャッジ時間 | 2,898 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 70 | 
ソースコード
#include <iostream>
#include <cmath>
#include <limits>
#include <functional>
using namespace std;
template <class F>
double integrate(F f, double lo, double hi, double eps = 1e-8) {
  const double th = eps / numeric_limits<double>::epsilon();
  function<double (double,double,double,double,int)> rec =
    [&](double x0, double x6, double y0, double y6, int d) {
      const double a = sqrt(2.0/3.0), b = 1.0 / sqrt(5.0);
      double x3 = (x0 + x6)/2, y3 = f(x3), h = (x6 - x0)/2;
      double x1 = x3-a*h, x2 = x3-b*h, x4 = x3+b*h, x5 = x3+a*h;
      double y1 = f(x1),  y2 = f(x2),  y4 = f(x4),  y5 = f(x5);
      double I1 = (y0+y6 + 5*(y2+y4)) * (h/6);
      double I2 = (77*(y0+y6) + 432*(y1+y5) + 625*(y2+y4) + 672*y3) * (h/1470);
      if (x3 + h == x3 || d > 50) return 0.0; 
      if (d > 4 && th + (I1-I2) == th) return I2; // avoid degeneracy
      return (double)(rec(x0, x1, y0, y1, d+1) + rec(x1, x2, y1, y2, d+1) 
          + rec(x2, x3, y2, y3, d+1) + rec(x3, x4, y3, y4, d+1) 
          + rec(x4, x5, y4, y5, d+1) + rec(x5, x6, y5, y6, d+1));
    };
  return rec(lo, hi, f(lo), f(hi), 0);
}
double circle_circle_intersection(double r, double d) {
  double D = 4*r*r - d*d;
  if (D < 0) {
    return 0;
  } else {
    return 2*r*r*acos(d/2/r)-d*sqrt(D)/2;
  }
}
int main(){
  double r, h, d;
  scanf("%lf %lf %lf", &r, &h, &d);
  r /= h;
  d /= h;
  double ans = integrate([&](double z) {
      return circle_circle_intersection(r*z, d);
  }, 0, 1, 1e-8);
  printf("%.12lf", ans*h*h*h);
}
            
            
            
        
            
tmaehara