結果

問題 No.172 UFOを捕まえろ
ユーザー startcppstartcpp
提出日時 2015-03-27 00:01:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 59,180 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 10:27:10
合計ジャッジ時間 1,626 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
using namespace std;

int x, y, r;

int main() {
	cin >> x >> y >> r;
	
	if ( x == 0 || y == 0 ) {
		int t = r * sqrt(2.0) + 1;
		cout << t << endl;
		return 0;
	}
	
	x = (x>0)?x:-x;
	y = (y>0)?y:-y;
	//(0,0)-(x,y)で直線を引く。この時の交点の内遠い方の距離が最も(0, 0)から遠い点。
	//半径をぶった切るので最も遠い点までの距離は「(x, y)までの長さ + 半径」となる。
	//ユーグリッド距離が大きいほどマンハッタン距離も大きくなっている感じがするので、適当にやる。
	double EPS = 1e-9;
	double X = x + r * (double)x/sqrt((double)x*x + y*y) - EPS;
	double Y = y + r * (double)y/sqrt((double)x*x + y*y) - EPS;
	
	int T = X + Y + 1;
	//cout << X << " " << Y << endl;
	cout << T << endl;
	return 0;
}
0