結果

問題 No.172 UFOを捕まえろ
ユーザー startcpp
提出日時 2015-03-27 00:15:59
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 335 ms / 5,000 ms
コード長 558 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 59,480 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 14:02:06
合計ジャッジ時間 9,321 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

//(マンハッタン距離的に)最も遠い点が問題。
#include<iostream>
#include<cmath>
using namespace std;

int x, y, r;

double distance(double rad) {
	double X = x + r * cos(rad);
	double Y = y + r * sin(rad);
	return X + Y;
}

int main() {
	cin >> x >> y >> r;
	
	x = (x>0)?x:-x;
	y = (y>0)?y:-y;
	
	int ans = 0;
	double PAI = 3.14159265358979;
	double EPS1 = 1e-6;
	double EPS2 = 1e-8;
	for(double rad = -2.0 * PAI; rad <= 2.0 * PAI; rad += EPS1) {
		int T = distance(rad) - EPS2 + 1;
		ans = max(T, ans);
	}
	cout << ans << endl;
	return 0;
}
0