結果

問題 No.172 UFOを捕まえろ
ユーザー kyuridenamidakyuridenamida
提出日時 2016-07-22 19:40:34
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 732 bytes
コンパイル時間 1,534 ms
コンパイル使用メモリ 161,936 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-06 08:45:43
合計ジャッジ時間 2,255 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef complex<double> P;

double x,y,r;
int ok(int D){
	vector<P> p;
	p.push_back(P(-D,0));
	p.push_back(P(+D,0));
	p.push_back(P(0,-D));
	p.push_back(P(0,+D));
	double a = 10000, b = -10000;
	double c = 10000, d = -10000;
	for(int i = 0 ; i < p.size() ; i++){
		p[i] *= P(1,1) / sqrt(2);
		a = min(a,p[i].real());
		b = max(b,p[i].real());
		c = min(c,p[i].imag());
		d = max(d,p[i].imag());
	}
	P q = P(x,y);
	q *= P(1,1) / sqrt(2);
	if( a <=  q.real()-r and q.real()+r <= b )
		if( c <=  q.imag()-r and q.imag()+r <= d )
			return true;
	return false;

}
int main(){
	
	cin >> x >> y >> r;
	for(int i = 0 ; i <= 1000 ; i++){
		if( ok(i) ){
			cout << i << endl;
			break;
		}
	}
}
0