結果
| 問題 | 
                            No.948 Bomb vs Dush
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-11-22 14:13:45 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 257 ms / 2,000 ms | 
| コード長 | 603 bytes | 
| コンパイル時間 | 1,363 ms | 
| コンパイル使用メモリ | 165,900 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-23 07:05:50 | 
| 合計ジャッジ時間 | 12,222 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 38 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
constexpr long double PI = 3.1415926535897932384626433;
//Euclidean distance
template<class T> T EucDist(T x1, T y1, T x2, T y2) {
    return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}
int main() {
	double r,R,ok = 180., ng = 360., md,x,y,d;
    cin >> r >> R;
	for(int i = 0; i < 1000000; ++i){
		md = (ok+ng)/2.;
		x = R*cos(md/180.*PI);
		y = R*sin(md/180.*PI);
		d = EucDist(x,y,R,0.);
		(2*r<=d?ok:ng)=md;
	}
	double area = PI*((R+r)*(R+r)-(R-r)*(R-r))*ok/360. + PI*r*r;
	double t = PI*ok/180.;
	printf("%.10f\n",t);
	printf("%.10f\n",area);
}