Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MAin {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int N;
- N = sc.nextInt();
- int paricki = N;
- int A=0, B=0, C=0, D=0, E=0;
- for(int a = 0; a <= N; a++) {
- for(int b = 0; b <= N; b++) {
- for(int c = 0; c <= N; c++) {
- for(int d = 0; d <= N; d++) {
- for(int e = 0; e <= N; e++) {
- if(a*50 + b*10 + c*5 + d*2 + e*1 == N) {
- if(paricki > a + b + c + d + e) {
- paricki = a + b + c + d + e;
- A = a;
- B = b;
- C = c;
- D = d;
- E = e;
- }
- }
- }
- }
- }
- }
- }
- System.out.println(paricki);
- System.out.println(A + " " + B + " " + C + " " + D + " " + E);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement