-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.java
40 lines (32 loc) · 814 Bytes
/
1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public class Main {
public static void main(String[] args) {
int n = 1260;
int cnt = 0;
int[] coinTypes = {500, 100, 50, 10};
for (int i = 0; i < 4; i++) {
int coin = coinTypes[i];
cnt += n / coin;
n %= coin;
}
System.out.println(cnt);
}
}
================================================================================
/*
import java.util.Scanner;
public class Greedy{
public static void main(String []args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int result = 0;
result += n/500;
n %= 500;
result += n/100;
n %= 100;
result += n/50;
n %= 50;
result += n/10;
System.out.println(result);
}
}
*/