結果
問題 | No.48 ロボットの操縦 |
ユーザー |
|
提出日時 | 2022-11-22 11:49:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 874 bytes |
コンパイル時間 | 608 ms |
コンパイル使用メモリ | 64,336 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 21:12:50 |
合計ジャッジ時間 | 1,419 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <iostream> using namespace std; int main() { int X, Y, L; cin >> X >> Y >> L; int total = 0; if (X == 0 && Y == 0) { cout << total << endl; return 0; } if (Y != 0) { total += (abs(Y) % L == 0) ? abs(Y) / L : (abs(Y) / L) + 1; // 北に進む } if (X != 0) { total += (abs(X) % L == 0) ? abs(X) / L : (abs(X) / L) + 1; // 東に進む } if (X == 0 && Y > 0) { total += 0; } else if (X == 0 && Y < 0) { total += 2; } else if (X > 0 && Y == 0) { total += 1; } else if (X < 0 && Y == 0) { total += 1; } else if (X > 0 && Y > 0) { total += 1; } else if (X > 0 && Y < 0) { total += 2; } else if (X < 0 && Y > 0) { total += 1; } else if (X < 0 && Y < 0) { total += 2; } cout << total << endl; }