210425_TIL

hyeojung·2021년 4월 25일
0

TIL

목록 보기
41/62
post-thumbnail

백준 알고리즘 1712번 : 손익분기점

#include <stdio.h>

int main(void)
{
	long long a, b, c;
	scanf("%llu %llu %llu", &a, &b, &c);

	if (b >= c)
	{
		printf("-1");
		return 0;
	}
	printf("%llu", a / (c - b) + 1);
	return 0;
}


백준 알고리즘 2292번 : 벌집

#include <stdio.h>

int main(void)
{
	long long n;
	int cnt = 2;
	int square = 1;
	scanf("%lld", &n);

	if (n == 1)
		cnt = 1;
	else
	{
		int i = 0;
		while (++i <= n)
		{
			square += (6 * i);
			if (square >= n)
				break;
			else
				cnt++;
		}
	}
	printf("%d", cnt);
}


백준 알고리즘 1193번 : 분수찾기

  • 아직 미완 ! 내일 마저 해야겠다
#include <stdio.h>

int main(void)
{
	int i = 0;
	int n = 0;
	int a, b; // 각각 분모, 분자
	int x;

	scanf("%d", &x);
	while (n < x)
		n += ++i; // i + 1 = 분모 + 분자
	a = 1;
	b = i;
	for (int j = 2; j <= x - n + i; j++)
	{
		a++;
		b--;
	}
	printf("%d/%d", a, b);
	return 0;
}


😂

수학 문제 풀려니까 왜 이렇게 어려울까,,? 머리 좀 써야겠다,,,,

profile
응애 나 애기 개발자

0개의 댓글