Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Task4 {
- public static void main(String[] args) {
- try(Scanner scan = new Scanner(System.in)){
- int magicWeight = Integer.parseInt(scan.nextLine());
- int[] values = {10, 20,30, 50, 80, 110, 130,160, 200, 240};
- int[] allValues = new int[100];
- int index = 0;
- for(int i =0; i<=9; i++){
- for(int j = 0; j<=9; j++){
- allValues[index]=values[i]+values[j]+40;
- ++index;
- }
- }
- int count = 0;
- for(int i = 0; i<=9; i++){
- for(int j = 0; j<=9; j++){
- for(int k = 0; k<100; k++){
- if(i==j){
- if(allValues[k]+4*i==magicWeight) ++count;
- } else{
- if(allValues[k]+3*i+j==magicWeight) ++count;
- if(allValues[k]+3*j+i==magicWeight) ++count;
- if(allValues[k]+2*i+2*j==magicWeight) count+=3;
- }
- }
- }
- }
- System.out.println(count);
- }
- }
- }
Add Comment
Please, Sign In to add comment