結果

問題 No.172 UFOを捕まえろ
コンテスト
ユーザー tadanoningen
提出日時 2020-09-19 11:30:13
言語 C++14
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 352µs
コード長 989 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 318 ms
コンパイル使用メモリ 80,512 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-27 18:39:45
合計ジャッジ時間 1,862 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/cstdlib:87,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/ext/string_conversions.h:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/basic_string.h:4442,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/string:56,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/locale_classes.h:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/ios_base.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/ios:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/ostream.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/iostream:43,
                 from main.cpp:1:
In function 'constexpr double std::abs(double)',
    inlined from 'int main()' at main.cpp:35:18:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/std_abs.h:78:30: warning: 'dist' may be used uninitialized [-Wmaybe-uninitialized]
   78 |   { return __builtin_fabs(__x); }
      |                              ^
main.cpp: In function 'int main()':
main.cpp:11:12: note: 'dist' was declared here
   11 |     double dist;
      |            ^~~~

ソースコード

diff #
raw source code

#include<iostream>
#include<cmath>
#include<string>

using namespace std;

int main(){
    double x,y,r;
    cin >> x >> y >> r;

    double dist;
    if(x > 0 && y > 0){
        dist = ceil(x + y + sqrt(2)*r);
    }else if(x < 0 && y > 0){
        dist = -x + y + sqrt(2)*r;
        if(dist > 0) dist = ceil(dist);
        else if(dist < 0) dist = floor(dist);
    }else if(x < 0 && y < 0){
        dist = floor(x + y - sqrt(2)*r);
    }else if(x > 0 && y < 0){
        dist = -x + y - sqrt(2)*r;
        if(dist > 0) dist = ceil(dist);
        else if(dist < 0) dist = floor(dist);
    }else if(x > 0 && y == 0){
        dist = ceil(x + sqrt(2)*r);
    }else if(x < 0 && y == 0){
        dist = floor(x - sqrt(2)*r);
    }else if(x == 0 && y > 0){
        dist = ceil(y + sqrt(2)*r);
    }else if(x == 0 && y < 0){
        dist = floor(y - sqrt(2)*r);
    }else if(x == 0 && y == 0){
        dist = ceil(sqrt(2)*r);
    }
    int ans = abs(dist);
    cout << ans << endl;
    return 0;
}
0