結果
問題 |
No.48 ロボットの操縦
|
ユーザー |
|
提出日時 | 2020-09-10 15:29:21 |
言語 | TypeScript (5.7.2) |
結果 |
AC
|
実行時間 | 66 ms / 5,000 ms |
コード長 | 848 bytes |
コンパイル時間 | 8,084 ms |
コンパイル使用メモリ | 228,600 KB |
実行使用メモリ | 41,328 KB |
最終ジャッジ日時 | 2024-12-31 16:19:26 |
合計ジャッジ時間 | 10,707 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
import { readFileSync } from 'fs'; function Main(input: string) { const data = input.split('\n'); const positionX = parseInt(data[0]); const positionY = parseInt(data[1]); const distance = parseInt(data[2]); let step = 0; // Y軸方向へ正方向の移動(↑)を行う場合 if (positionY > 0) { step += Math.ceil(positionY / distance); } // X軸へ移動(←→)を行う場合 // 絶対値を取って計算する if (positionX !== 0) { step++; // 回転 step += Math.ceil(Math.abs(positionX) / distance); } // Y軸方向へ負方向の移動(↓)を行う場合 if (positionY < 0) { if (positionX === 0) { step += 2; } else { step++; } step += Math.ceil((-1 * positionY) / distance); } console.log(step); } Main(readFileSync('/dev/stdin', 'utf8'));