프로그래밍/코딩 문제 풀이

프로그래머스 2023.06.05 (2Lv 점 찍기)

Rozentea 2023. 6. 19. 16:48

문제


코딩


#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

long long solution(int k, int d) {
	long long answer = 0;

	int inum_x = 0;
	int inum_y = 0;

	while (true)
	{
		if (inum_x * k > d)
			break;

		inum_y = 0;
		while (true)
		{
			if (sqrt(pow(inum_x * k, 2) + pow(inum_y * k, 2)) > d)
			{
				answer += inum_y;
				break;
			}
			inum_y++;
		}

		inum_x++;
	}

	return answer;
}

실행 결과