baekjoon 1075

호진·2021년 12월 6일
0

baekjoon

목록 보기
3/39

https://www.acmicpc.net/problem/1075



Idea

이 문제는 함정이라고 하긴 뭐 하지만 함정같지 않은 함정이 있다.
나누어 떨어지는 분자를 찾아야 하는데 주어진 값에서 나누어 떨어지지 않으면 끝에 두 자리를 바꿔야하고 가능한 작게 만들어야 한다. 잘 봐야할 것은 100의 자리는 바뀌면 안 된다는 것이다. 그래서 for문을 0에서 99까지가 아닌 99에서 1씩 감소하여 0까지 떨어트리는 방식으로 문제를 풀었다. 이것도 뭐 쉬워서..


Code

#define _CRT_SECURE_NO_WARNINGS
#define SEATS 100

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


// baekjoon 1075
// algorithm .math

int main(void) {
	int N;
	int F;
	int hun_seats = 0;	
	int result = 0;

	scanf("%d %d", &N, &F);

	hun_seats = (N / SEATS) * SEATS + SEATS;

	for (int i = 100; i > 0; i--) {
		hun_seats--;

		if (hun_seats % F == 0) {
			result = hun_seats;
		}
	}

	result %= SEATS;
	
	if (result < 10) {
		printf("0");
	}

	printf("%d", result);
	
	return 0;
}

헤헷

profile
💭(。•̀ᴗ-)✧

0개의 댓글