結果

問題 No.48 ロボットの操縦
ユーザー kpinkcat
提出日時 2023-08-04 14:27:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 471 bytes
コンパイル時間 983 ms
コンパイル使用メモリ 102,652 KB
最終ジャッジ日時 2025-02-15 21:55:39
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:20: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   16 |     if (y < 0) ans += 2;
      |                ~~~~^~~~
main.cpp:14:24: note: ‘ans’ was declared here
   14 |     long long x, y, l, ans;
      |                        ^~~

ソースコード

diff #

#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(){
    long long x, y, l, ans;
    cin >> x >> y >> l;
    if (y < 0) ans += 2;
    else if (abs(x)) ans++;
    if (!(y%l)) ans += abs(y)/l;
    else ans += (abs(y)/l + 1);
    if (!(abs(x)%l)) ans += abs(x)/l;
    else ans += (abs(x)/l + 1);

    cout << ans << endl;
}
0