Advertisement
dim4o

MagicCarNumbers

Aug 13th, 2014
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MagicCarNumbers
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             char[] arr = {'A', 'B', 'C', 'E', 'H', 'K', 'M', 'P', 'T', 'X'};
  10.             int magicWeight = int.Parse(Console.ReadLine());
  11.             int weight = 0;
  12.             int count = 0;
  13.  
  14.             for (int i = 0; i < arr.Length; i++)
  15.             {
  16.                 for (int k = 0; k < arr.Length; k++)
  17.                 {
  18.                     weight = ((int)arr[i] + (int)arr[k] - 128) * 10;
  19.                     for (int a = 0; a < 10; a++)
  20.                     {
  21.                         if (4 * a + 40 + weight == magicWeight)
  22.                         {
  23.                             count++;
  24.                         }
  25.  
  26.                         for (int b = 0; b < 10; b++)
  27.                         {
  28.                             if (a != b)
  29.                             {
  30.                                 if (3 * b + a + 40 + weight == magicWeight)
  31.                                 {
  32.                                     count++;
  33.                                 }
  34.                                 if (3 * a + b + 40 + weight == magicWeight)
  35.                                 {
  36.                                     count++;
  37.                                 }
  38.                                 if (2 * a + 2 * b + 40 + weight == magicWeight)
  39.                                 {
  40.                                     count += 3;
  41.                                 }
  42.                             }
  43.                         }
  44.                     }
  45.                 }
  46.             }
  47.             Console.WriteLine(count);
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement