본문 바로가기
알고리즘 & 자료구조/백준

백준 5585

by 신재권 2021. 11. 1.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main5585 {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine()); //지불할 돈 N
		N = 1000 - N;
		
		int coinType[] = {500, 100, 50, 10 ,5, 1};
		int cnt = 0;
		
		for(int i=0; i<coinType.length; i++){
			cnt += N/coinType[i];
			N %= coinType[i];
		}
		System.out.println(cnt);
	}

}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 1931  (0) 2021.11.03
백준 11047  (0) 2021.11.02
백준 1107  (0) 2021.09.30
백준 1476  (0) 2021.09.25
백준 3085  (0) 2021.09.23