본문 바로가기

백준

5585 거스름돈

 

 


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
	
 public static void main(String[] args) throws IOException {
	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 int N = Integer.parseInt(br.readLine());
	 int remain = 1000 - N;
	 int []coin = {500,100,50,10,5,1};
	 int cnt = 0;
	 int index = 0;
	 while(remain >= 5) {
		 cnt += remain/coin[index];
		 remain %= coin[index];
		 index++;
	 }
	 System.out.println(cnt+remain);
 }
}

'백준' 카테고리의 다른 글

1654 랜선 자르기  (0) 2021.10.23
10869 사칙연산  (0) 2021.10.18
2475 검증수  (0) 2021.10.14
1546 평균  (0) 2021.10.12
2438 별찍기  (0) 2021.10.12