結果
問題 | No.48 ロボットの操縦 |
ユーザー |
|
提出日時 | 2016-03-27 15:21:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 870 bytes |
コンパイル時間 | 449 ms |
コンパイル使用メモリ | 58,360 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 18:36:33 |
合計ジャッジ時間 | 1,212 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <iostream> #include <cmath> using namespace std; int walkcount(int a, int b) { if ((a % b) == 0) { return (static_cast<int>(abs(a)) / b); } else { return (static_cast<int>(abs(a)) / b + 1); } } int main() { int x, y, l; cin >> x >> y >> l; int ans = 0; if (y == 0) { if (x != 0) { ans = walkcount(x, l); ans++; } } else if (0 < y) { if (x == 0) { ans = walkcount(y, l); } else if (x != 0) { ans = walkcount(y, l) + walkcount(x, l); ans++; } } else if (y < 0) { if (x == 0) { ans = walkcount(y, l); ans += 2; } else if (x != 0) { ans = walkcount(y, l) + walkcount(x, l); ans += 2; } } cout << ans <<endl; return 0; }