-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package BAEKJOON; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
public class BOJ_5585 { | ||
public static void main(String[] args) throws IOException { | ||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
int N = Integer.parseInt(br.readLine()); | ||
int paymoney = 1000 - N ; | ||
int[] arr ={500, 100, 50, 10, 5, 1}; | ||
int i = 0; | ||
int change = 0; | ||
while (paymoney != 0){ | ||
if (paymoney / arr[i] > 0 ){ | ||
change = change + paymoney / arr[i]; //1 , 2 | ||
paymoney = paymoney % arr[i]; //120 , 20 | ||
|
||
} | ||
else { | ||
i++; | ||
} | ||
} | ||
System.out.println(change); | ||
} | ||
} |