結果
| 問題 |
No.48 ロボットの操縦
|
| コンテスト | |
| ユーザー |
kpinkcat
|
| 提出日時 | 2023-08-04 13:47:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 539 bytes |
| コンパイル時間 | 943 ms |
| コンパイル使用メモリ | 104,352 KB |
| 最終ジャッジ日時 | 2025-02-15 21:55:32 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:25: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
17 | if (!(y%l)) ans += y/l;
| ~~~~^~~~~~
main.cpp:14:18: note: ‘ans’ was declared here
14 | int x, y, l, ans;
| ^~~
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
using namespace std;
int main(){
int x, y, l, ans;
cin >> x >> y >> l;
if (y >= 0){
if (!(y%l)) ans += y/l;
else ans += (y/l + 1);
} else {
if (y%l) ans += (-y/l + 1);
else ans += (-y/l + 2);
}
if (abs(x) || abs(x)%l) ans += (abs(x)/l + 1);
else if (abs(x)) ans += (abs(x/l) + 2);
cout << ans << endl;
}
kpinkcat