Skip to content

Commit

Permalink
Baekjoon #14916 : 거스름돈
Browse files Browse the repository at this point in the history
Baekjoon #14916 : 거스름돈
Merge pull request #9 from allrightDJ0108/macDev
  • Loading branch information
allrightDJ0108 committed Oct 30, 2023
2 parents c2bd334 + 282bfd1 commit 4b87c80
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Binary file added CodingTestStudy1.0/bin/Greedy/Problem14916.class
Binary file not shown.
32 changes: 32 additions & 0 deletions CodingTestStudy1.0/src/Greedy/Problem14916.java
@@ -0,0 +1,32 @@
package Greedy;

import java.io.*;

public class Problem14916 {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int N = Integer.parseInt(br.readLine());

int cnt = 0;

while (N > 0){
//System.out.println(N);
if (N % 5 == 0){
cnt += N / 5;
N = N % 5;
} else {
N = N - 2;
cnt++;
}

}

if (N < 0) {
System.out.println(-1);
} else {
System.out.println(cnt);
}

}
}

0 comments on commit 4b87c80

Please sign in to comment.