結果

問題 No.948 Bomb vs Dush
ユーザー ningenMe
提出日時 2019-11-22 15:26:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 635 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 166,208 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-11 02:35:37
合計ジャッジ時間 7,427 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 38
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:11:13: warning: 'r' is used uninitialized [-Wuninitialized]
   11 |     assert(0<r&&r+0.01<R&&R<=100.);
      |             ^
main.cpp:10:16: note: 'r' declared here
   10 |         double r,R,ok = 180., ng = 360., md,x,y,d;
      |                ^
main.cpp:11:23: warning: 'R' may be used uninitialized [-Wmaybe-uninitialized]
   11 |     assert(0<r&&r+0.01<R&&R<=100.);
      |                       ^
main.cpp:10:18: note: 'R' declared here
   10 |         double r,R,ok = 180., ng = 360., md,x,y,d;
      |                  ^

ソースコード

diff #

#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;
    assert(0<r&&r+0.01<R&&R<=100.);
    cin >> r >> R;
	for(int i = 0; i < 10000; ++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("%.5f\n",t);
	printf("%.5f\n",area);
}
0