結果
問題 |
No.48 ロボットの操縦
|
ユーザー |
|
提出日時 | 2017-07-05 10:01:10 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 549 bytes |
コンパイル時間 | 1,251 ms |
コンパイル使用メモリ | 159,596 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-05 19:46:11 |
合計ジャッジ時間 | 2,033 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d%d%d", &X, &Y, &L); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; int move(int rem, int len) { int r = abs(rem); return abs(r / len) + (r % len > 0 ? 1 : 0); } int main(int argc, char **argv) { int X, Y, L; scanf("%d%d%d", &X, &Y, &L); int cnt = 0; if (Y >= 0) { if (Y != 0) { cnt += move(Y, L); } if (X != 0) { cnt += 1; cnt += move(X, L); } } else { if (X != 0) { cnt += 1; cnt += move(X, L); } if (X == 0 && Y != 0) { cnt++; } if (Y != 0) { cnt += 1; cnt += move(Y, L); } } printf("%d\n", cnt); return 0; }