結果
問題 |
No.1319 最強とんがりコーン
|
ユーザー |
|
提出日時 | 2020-12-08 11:40:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 581 bytes |
コンパイル時間 | 2,228 ms |
コンパイル使用メモリ | 193,064 KB |
最終ジャッジ日時 | 2025-01-16 19:34:45 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; 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); }