結果

問題 No.172 UFOを捕まえろ
ユーザー MamonboMamonbo
提出日時 2015-10-14 17:53:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 1,016 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-23 14:22:28
合計ジャッジ時間 1,638 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#coding=UTF-8
#思い出した!点と直線の距離の公式だ!
#直線ax+by+c=0について点(x_1,y_1)との距離は
#\frac{|ax_1+by_1+c|}{\root{a^2+b^2}}
#x+y-N=0について(距離)>rになるのは
#|x_1+y_1-N|>\root{2} r
#Nがめちゃくちゃ大きければ閉じ込められるので絶対値の中身は負のときを考えればいい
#N-x_1-y_1>\root{2} r
#N>x_1+y_1+\root{2} r

#4つの直線に囲まれているのは傾きが±になっているを使う
#x+y+N=0のほうは-x-y-N=0とすればよい
#±x_1±y_1+\root{2} rの最大値を求め、それを越える最小の整数を返せばいぇーい

#r in [1,100]なら1.41421ぐらいいれとけば足りるとは思うけどね
mojir=input()
hyo=mojir.split(' ')
x=int(hyo[0])
y=int(hyo[1])
r=int(hyo[2])

#2分探索
kagen=r#以下
jogen=r*2#より大きい
while jogen-kagen>1:
    if ((jogen+kagen)//2)**2 > 2*(r**2):
        jogen=(jogen+kagen)//2
    else:
        kagen=(jogen+kagen)//2

ans=abs(x)+abs(y)+jogen
print(ans)        
0