結果
問題 |
No.48 ロボットの操縦
|
ユーザー |
![]() |
提出日時 | 2018-10-29 13:39:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 801 bytes |
コンパイル時間 | 1,366 ms |
コンパイル使用メモリ | 158,136 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-19 07:37:24 |
合計ジャッジ時間 | 1,999 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 6 |
ソースコード
#include <bits/stdc++.h> int go_forward(int dest_pos, int allowed_distance) { int dest_pos_abs = std::abs(dest_pos); if (dest_pos_abs <= allowed_distance) { return 1; } int mod = dest_pos_abs % allowed_distance; int quo = dest_pos_abs / allowed_distance; return (mod == 0) ? quo : quo + 1; } int main(int argc, char *argv[]) { int dest_x = 0; int dest_y = 0; int allowed_distance = 0; int order_count = 0; std::cin >> dest_x; std::cin >> dest_y; std::cin >> allowed_distance; // y axis if (dest_y != 0) { if (dest_y < 0) { order_count += 2; } order_count += go_forward(dest_y, allowed_distance); } // x axis if (dest_x != 0) { order_count += 1; order_count += go_forward(dest_x, allowed_distance); } std::cout << order_count << std::endl; return 0; }