VioletaBabel

2839번: 설탕 배달 본문

백준/백준-C
2839번: 설탕 배달
Beabletoet 2017. 5. 14. 15:35

#include <stdio.h>

int main()

{

int N, copyN, five = 0, three;

scanf("%d", &N);

five = N / 5; // 2

while (five >= 0)

{

copyN = N - (five * 5); // 6

three = copyN / 3;

if (copyN % 3 == 0)

break;

--five;

}

(N != (five * 5 + three * 3)) ? printf("-1") : printf("%d", five + three);

}

'백준 > 백준-C' 카테고리의 다른 글

2607번: 비슷한 단어  (0) 2017.05.16
9426번: 중앙값 측정 (실패)  (0) 2017.05.15
14579번: 덧셈과 곱셈  (0) 2017.05.14
2980번: 도로와 신호등  (0) 2017.05.13
5063번: TGN  (0) 2017.05.13
Comments