結果
問題 |
No.48 ロボットの操縦
|
ユーザー |
![]() |
提出日時 | 2016-05-30 20:23:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 716 bytes |
コンパイル時間 | 230 ms |
コンパイル使用メモリ | 23,296 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 19:24:48 |
合計ジャッジ時間 | 5,144 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:60:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 60 | printf ("%d\n", count); | ~^ ~~~~~ | | | | int long long int | %lld main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d %d %d", &X, &Y, &L); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #define ll long long int main(void) { int X, Y, L; ll x = 0, y = 0; ll count = 0; scanf("%d %d %d", &X, &Y, &L); if(X > 0 && y >= 0){ count = 1; } else if(X < 0 && Y >= 0){ count = 1; } else if(X <= 0 && Y < 0){ count = 2; } else if(X > 0 && Y < 0){ count = 2; } for(; (X != x) || (Y != y); ++count){ if(X > x){ if(X-x > L){ x = x + L; } else { x = X; } } else if(X < x){ if(x-X > L){ x = x - L; } else { x = X; } } else if(Y > y){ if(Y-y > L){ y = y + L; } else { y = Y; } } else if(Y < y){ if(y-Y > L){ y = y - L; } else { y = Y; } } } printf ("%d\n", count); return 0; }