結果

問題 No.172 UFOを捕まえろ
ユーザー omochana1omochana1
提出日時 2015-03-26 23:43:04
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,355 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 82,144 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 13:59:56
合計ジャッジ時間 1,365 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <map>
#include <fstream>
#include <functional>
#include <bitset>
#include <stack>
#include <set>
#include <climits>
#define MAX_N 100010
#define LOG 21
#define PI 3.141592653589
#define EPS 1e-6
#define MOD 1000000007
#define YJSNPI 810
#define INF (1 << 30)
#define ADD(a, b) a = (a + (ll)b) % MOD
#define MUL(a, b) a = (a * (ll)b) % MOD
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define x first
#define y second
#define REP(i, a, b) for(int i = a; i < b; i++)
#define RER(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair<ll, int> pi;

void debug() {cout << endl; }

template<class FIRST, class... REST>
void debug(FIRST arg, REST... rest) { cout << arg << " "; debug(rest...); }

template<class T>
void showary(T begin, T end) { 
	while(begin != end) { cout << *begin << " "; begin++; } cout << endl; }

int x, y, r;

int dx[4] = {1, 1, -1, -1};
int dy[4] = {1, -1, 1, -1};

int main() {
	cin >> x >> y >> r;
	int a = abs(x) + abs(y);
	while(true) {
		bool ok = true;
		REP(i, 0, 4) {
			if(abs(x * dx[i] + y + a * dy[i]) / sqrt(2) < r) {
				ok = false;
				break;
			}
		}
		if(ok) break;
		a++;
	}
	cout << a << endl;
}
0