結果

問題 No.172 UFOを捕まえろ
ユーザー hadrori
提出日時 2015-07-25 22:36:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 627 bytes
コンパイル時間 1,688 ms
コンパイル使用メモリ 157,012 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 14:13:08
合計ジャッジ時間 2,410 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void input()’:
main.cpp:27:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |     scanf("%d%d%d", &x, &y, &r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repi(i,0,n)

inline int sq(int x) { return x*x; }
int x, y, r;

bool ok(int m) {
    const int cx = (m+x-y)*5, cy = -cx+m*10;
    return sq(10*r) < sq(cx-10*x)+sq(cy-10*y);
}

int solve() {
    if(x < 0) x *= -1;
    if(y < 0) y *= -1;
    int lb = x+y+r, ub = 1024, m;
    while(ub-lb > 1) {
        m = (lb+ub)/2;
        if(ok(m)) ub = m;
        else lb = m;
    }
    return ub;
}

void input() {
    scanf("%d%d%d", &x, &y, &r);
}

int main() {
    input();
    printf("%d\n", solve());
    return 0;
}
0