結果
問題 |
No.48 ロボットの操縦
|
ユーザー |
![]() |
提出日時 | 2016-05-30 20:24:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 715 bytes |
コンパイル時間 | 316 ms |
コンパイル使用メモリ | 23,040 KB |
実行使用メモリ | 8,228 KB |
最終ジャッジ日時 | 2024-10-07 19:25:10 |
合計ジャッジ時間 | 7,747 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 2 TLE * 1 -- * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:11: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=] 9 | scanf("%d %d %d", &X, &Y, &L); | ~^ ~~ | | | | int* long long int* | %lld main.cpp:9:14: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long long int*’ [-Wformat=] 9 | scanf("%d %d %d", &X, &Y, &L); | ~^ ~~ | | | | int* long long int* | %lld main.cpp:9:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 4 has type ‘long long int*’ [-Wformat=] 9 | scanf("%d %d %d", &X, &Y, &L); | ~^ ~~ | | | | int* long long int* | %lld 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) { ll 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; }