dentia

magic, car, weight, java, softuni

May 26th, 2014
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Task4 {
  4.  
  5.    
  6.     public static void main(String[] args) {
  7.        
  8.        try(Scanner scan = new Scanner(System.in)){
  9.            int magicWeight = Integer.parseInt(scan.nextLine());
  10.            int[] values = {10, 20,30, 50, 80, 110, 130,160, 200, 240};
  11.            int[] allValues = new int[100];
  12.            int index = 0;
  13.            for(int i =0; i<=9; i++){
  14.             for(int j = 0; j<=9; j++){
  15.                 allValues[index]=values[i]+values[j]+40;
  16.                 ++index;
  17.             }
  18.            }
  19.            int count = 0;
  20.            for(int i = 0; i<=9; i++){
  21.                for(int j = 0; j<=9; j++){
  22.                    for(int k = 0; k<100; k++){
  23.                        if(i==j){
  24.                          if(allValues[k]+4*i==magicWeight) ++count;
  25.                        } else{
  26.                            if(allValues[k]+3*i+j==magicWeight) ++count;
  27.                            if(allValues[k]+3*j+i==magicWeight) ++count;
  28.                            if(allValues[k]+2*i+2*j==magicWeight) count+=3;
  29.                        }
  30.                    }
  31.                }
  32.            }
  33.            System.out.println(count);
  34.        }  
  35.     }
  36. }
Add Comment
Please, Sign In to add comment