Submission #949761

# Submission time Handle Problem Language Result Execution time Memory
949761 2024-03-19T16:18:21 Z rainboy 직사각형 게임 (KPI13_game) C
Compilation error
0 ms 0 KB
#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

game.c: In function 'main':
game.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d%d%d", &a, &b, &c, &d), z = hypot(c, d);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccnq8XV8.o: in function `main':
game.c:(.text.startup+0x51): undefined reference to `hypot'
/usr/bin/ld: game.c:(.text.startup+0x98): undefined reference to `atan2'
/usr/bin/ld: game.c:(.text.startup+0x15a): undefined reference to `acos'
/usr/bin/ld: game.c:(.text.startup+0x179): undefined reference to `sincos'
/usr/bin/ld: game.c:(.text.startup+0x214): undefined reference to `sincos'
/usr/bin/ld: game.c:(.text.startup+0x29a): undefined reference to `asin'
/usr/bin/ld: game.c:(.text.startup+0x2b9): undefined reference to `sincos'
/usr/bin/ld: game.c:(.text.startup+0x353): undefined reference to `sincos'
collect2: error: ld returned 1 exit status