結果
問題 |
No.1319 最強とんがりコーン
|
ユーザー |
|
提出日時 | 2020-12-08 11:43:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 2,069 ms |
コンパイル使用メモリ | 193,360 KB |
最終ジャッジ日時 | 2025-01-16 19:36:22 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 70 |
ソースコード
#include<bits/stdc++.h> #define dvd 1000000 using namespace std; //https://mathworld.wolfram.com/Circle-CircleIntersection.html double f(double r,double d){ if(2*r <= d){return 0.0;} double ac=acos(d/(2.0*r)),res,subt; res=2.0*r*r*ac; subt=0.5*d; subt*=sqrt((4.0*r*r-d*d)); return res-subt; } int main(){ double r,h,d,res=0.0; double s1,s2,bh; cin >> r >> h >> d; assert(r<=10000.0 && h<=10000.0); assert(d <= 2.0*r); bh=(h/(double)dvd); s1=f(r,d); for(int i=1;i<=dvd;i++){ double cr=r*(((double)(dvd-i))/((double)dvd)); s2=f(cr,d); res+=(s1+s2); s1=s2; } printf("%.12lf\n",res*bh/2.0); }