Submission #944520

# Submission time Handle Problem Language Result Execution time Memory
944520 2024-03-12T21:07:34 Z rainboy 제곱근 구하기 2 (gs13068_sqrt2) C
Compilation error
0 ms 0 KB
#include <math.h>
#include <stdio.h>

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

int main() {
	long long n, r;

	scanf("%lld", &n);
	r = sqrt(n);
	while (abs_(r * r - n) > abs_((r + 1) * (r + 1) - n))
		r++;
	while (abs_(r * r - n) > abs_((r - 1) * (r - 1) - n))
		r--;
	printf("%f\n", (double) r / 2 + (double) n / r / 2);
	return 0;
}

Compilation message

sqrt2.c: In function 'main':
sqrt2.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%lld", &n);
      |  ^~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccoJK3Y6.o: in function `main':
sqrt2.c:(.text.startup+0x114): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status