結果

問題 No.172 UFOを捕まえろ
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-03-27 00:17:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,577 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 86,552 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-05 16:58:14
合計ジャッジ時間 1,910 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,504 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(long long i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000007

int x,y,r;

int f1(int ax, int ay, int bx, int by, int cx, int cy){
  int x1 = (bx-ax);
  int y1 = (by-ay);
  int x2 = (cx-ax);
  int y2 = (cy-ay);
  return x1 * y2 - y1 * x2;
}

void abc(int x1, int y1, int x2, int y2, int &a, int &b, int &c){
  a = y2 - y1;
  b = x1 - x2;
  c = x2 * y1 - x1 * y2;
}

double distpl(int x, int y, int a, int b, long long c){
  if(a == 0 && b == 0)return -1.0;
  long long n = llabs((long long)a * x + (long long)b * y + c);
  return (double)n / sqrt(a * a + b * b);
}

int f(int p){
  int d[4][4] ={
    {-p,0,0,p},
    {0,p,p,0},
    {p,0,0,-p},
    {0,-p,-p,0}
  };
  int flag = 1;
  rep(i,0,4){
    if(f1(d[i][0],d[i][1],d[i][2],d[i][3],x,y)>0)flag=0;
    int a,b,c;
    abc(d[i][0],d[i][1],d[i][2],d[i][3],a,b,c);
    if(distpl(x,y,a,b,c)<r){
      flag = 0;
    }
  }
  return flag;
}

int main(){
  cin>>x>>y>>r;
  rep(i,1,10000){
    if(f(i)==1){
      cout << i << endl;
      break;
    }
  }
  return 0;
}
0