Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MagicCarNumbers {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- long magicWeight = scanner.nextLong();
- long sum = 40;
- int counter = 0;
- int[] weight = {10, 20, 30, 50, 80, 110, 130, 160, 200, 240};
- for (int i1 = 0; i1 <= 9; i1++) {
- for (int i2 = 0; i2 <= 9; i2++) {
- for (int i3 = 0 ; i3 <= 9; i3++) {
- for (int i4 = 0 ; i4 <= 9; i4++) {
- for (int i5 = 0; i5 < weight.length; i5++) {
- for (int i6 = 0; i6 < weight.length; i6++) {
- sum += + i1 + i2 + i3 + i4 + weight[i5] + weight[i6];
- if (magicWeight == sum) {
- if(i1 == i2 && i2 == i3 && i3 == i4 ) { counter ++;} //aaaa
- else if ( i1 != i2 && i2 == i3 && i3 == i4) { counter++;} //abbb
- else if ( i1 == i2 && i2 == i3 && i3 != i4) { counter++;} //aaab
- else if ( i1 == i2 && i2 != i3 && i3 == i4) { counter++;} //aabb
- else if ( i1 == i3 && i1 != i2 && i2 == i4) { counter++;} //abab
- else if ( i1 == i4 && i1 != i2 && i2 == i3) { counter++;} //abba
- }
- sum = 40;
- }
- }
- }
- }
- }
- }
- System.out.println(counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment