Submission #949762

#TimeUsernameProblemLanguageResultExecution timeMemory
949762rainboy직사각형 게임 (KPI13_game)C++17
1 / 1
1 ms604 KiB
#include <math.h>
#include <stdio.h>

#define eps	1e-9

double abs_(double a) { return a > 0 ? a : -a; }

int main() {
	double alpha, beta, z;
	int a, b, c, d, tmp, first;

	scanf("%d%d%d%d", &a, &b, &c, &d), z = hypot(c, d);
	if (a < b)
		tmp = a, a = b, b = tmp;
	if (c < d)
		tmp = c, c = d, d = tmp;
	alpha = atan2(d, c) * 2;
	first = 0;
	if (b >= z)
		first = 1;
	else if (a * a + b * b < c * c + d * d)
		first = 0;
	else {
		if (b * b <= c * c + d * d) {
			beta = asin((double) b / z);
			if (abs_(z * cos(beta + alpha)) <= a + eps && abs_(z * sin(beta + alpha)) <= b + eps)
				first = 1;
			if (abs_(z * cos(beta - alpha)) <= a + eps && abs_(z * sin(beta - alpha)) <= b + eps)
				first = 1;
		}
		if (a * a <= c * c + d * d) {
			beta = acos((double) a / z);
			if (abs_(z * cos(beta + alpha)) <= a + eps && abs_(z * sin(beta + alpha)) <= b + eps)
				first = 1;
			if (abs_(z * cos(beta - alpha)) <= a + eps && abs_(z * sin(beta - alpha)) <= b + eps)
				first = 1;
		}
	}
	printf(first ? "First\n" : "Second\n");
	return 0;
}

Compilation message (stderr)

game.cpp: In function 'int main()':
game.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d%d%d", &a, &b, &c, &d), z = hypot(c, d);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...