svetlozar_kirkov

Magic Car Numbers

Sep 23rd, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace MagicCarNumbers
  5. {
  6.     class MagicCarNumbers
  7.     {
  8.         static void Main()
  9.         {
  10.             int magicWeight = int.Parse(Console.ReadLine());
  11.             char[] letters = new char[10] { 'A', 'B', 'C', 'E', 'H', 'K', 'M', 'P', 'T', 'X' };
  12.             int[] lettersWeight = new int[10] { 10, 20, 30, 50, 80, 110, 130, 160, 200, 240 };
  13.             int count = 0;
  14.  
  15.             for (int i = 0; i < 10; i++)
  16.             {
  17.                 for (int j = 0; j < 10; j++)
  18.                 {
  19.                     for (int k = 0; k < 10; k++)
  20.                     {
  21.                         for (int m = 0; m < 10; m++)
  22.                         {
  23.                             for (int n = 0; n < 10; n++)
  24.                             {
  25.                                 for (int p = 0; p < 10; p++)
  26.                                 {
  27.                                     int tempSum = 40 + i + j + k + m + lettersWeight[n] + lettersWeight[p];
  28.                                    
  29.                                     if (tempSum == magicWeight && i != j && j == k && k == m || tempSum == magicWeight && i == j &&
  30.                                         j == k && k == m || tempSum == magicWeight && i == j && j == k && k != m || tempSum == magicWeight &&
  31.                                         i == j && j != k && k == m || tempSum == magicWeight && i == k && j == m && i!=j ||
  32.                                         tempSum == magicWeight && i == m && i !=j && j==k)
  33.                                     {
  34.                                         count++;
  35.                                     }
  36.                                 }
  37.                             }
  38.                         }
  39.                     }
  40.                 }
  41.             }
  42.  
  43.             Console.WriteLine(count);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment