結果

問題 No.605 板挟みの球面
ユーザー pekempeypekempey
提出日時 2017-12-05 00:28:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 72,256 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 21:58:15
合計ジャッジ時間 1,196 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,380 KB
testcase_01 AC 9 ms
4,380 KB
testcase_02 AC 9 ms
4,376 KB
testcase_03 AC 9 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

const double pi = acos(-1);

int main() {
  double a, b;
  cin >> a >> b;

  double ans = 0;
  const int N = 1e6;
  double dx = (b - a) / N;
  for (int i = 0; i < N; i++) {
    double x1 = a + i*dx;
    double x2 = a + (i+1)*dx;
    double y1 = sqrt(1-x1*x1);
    double y2 = sqrt(1-x2*x2);
    ans += pi * (y1+y2) * sqrt(dx*dx+(y2-y1)*(y2-y1));
  }

  printf("%.20f\n", (double)ans);
}
0