結果
問題 | No.48 ロボットの操縦 |
ユーザー |
![]() |
提出日時 | 2019-07-14 20:01:25 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 760 bytes |
コンパイル時間 | 84 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-11-24 14:52:30 |
合計ジャッジ時間 | 1,508 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
def count_prog(start, end, prog): distance = end - start if distance < 0: distance *= -1 if distance % prog == 0: count = distance // prog else: count = (distance // prog) + 1 return count (TARGET_X) = int(input().rstrip()) (TARGET_Y) = int(input().rstrip()) (MAX_PROG) = int(input().rstrip()) nof_ope = 0 # 回転する回数を数える # ---Y--- # |+|0|-| # |+|1|1|2| # X0|0|0|2| # |-|1|1|2| if TARGET_Y < 0: nof_ope += 2 elif TARGET_Y == 0: if TARGET_X != 0: nof_ope += 1 elif TARGET_X != 0: nof_ope += 1 # 南北の移動回数を求める nof_ope += count_prog(0, TARGET_Y, MAX_PROG) # 東西の移動回数を求める nof_ope += count_prog(0, TARGET_X, MAX_PROG) print(nof_ope)