結果

問題 No.172 UFOを捕まえろ
ユーザー nmnmnmnmnmnmnm
提出日時 2015-03-27 00:17:46
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,577 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 89,636 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 14:02:10
合計ジャッジ時間 1,515 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1