結果
問題 |
No.48 ロボットの操縦
|
ユーザー |
![]() |
提出日時 | 2018-10-29 13:46:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 926 bytes |
コンパイル時間 | 1,293 ms |
コンパイル使用メモリ | 159,008 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-19 07:38:23 |
合計ジャッジ時間 | 2,027 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 1 |
ソースコード
#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; // x axis if (dest_x != 0) { // まずx軸を回転させたほうが、y を回転させるときの // 命令数が小さくなる order_count += 1; order_count += go_forward(dest_x, allowed_distance); } // y axis if (dest_y != 0) { if (dest_y < 0) { order_count += 1; // y を回転 } order_count += go_forward(dest_y, allowed_distance); } std::cout << order_count << std::endl; return 0; }