Advertisement
Guest User

04.Magic Car Numbers

a guest
Apr 14th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Numerics;
  6. using System.Threading.Tasks;
  7.  
  8. class Program
  9. {
  10.     static void Main()
  11.     {
  12.         int CA = 40;
  13.         int input = int.Parse(Console.ReadLine());
  14.         int[] letters = { 10, 20, 30, 50, 80, 110, 130, 160, 200, 240 };
  15.         int count = 0;
  16.         for(int a = 0;a<10;a++)
  17.         {
  18.             for (int b = 0; b < 10; b++)
  19.             {
  20.                 for (int c = 0; c < 10; c++)
  21.                 {
  22.                     for (int d = 0; d < 10; d++)
  23.                     {
  24.                         for (int e = 0; e < 10; e++)
  25.                         {
  26.                             for (int f = 0; f < 10; f++)
  27.                             {
  28.                                 int tempresult = CA + a + b + c + d + letters[e] + letters[f];
  29.                                 if(tempresult==input)
  30.                                 {
  31.                                     if(a==b)
  32.                                     {
  33.                                         if(b==c && c==d)
  34.                                         {
  35.                                             count++;
  36.                                         }
  37.                                         else if(b==c && c!=d)
  38.                                         {
  39.                                             count++;
  40.                                         }
  41.                                         else if(c!=a && c==d)
  42.                                         {
  43.                                             count++;
  44.                                         }
  45.                                     }
  46.                                     else if(a!=b && b==c && c==d)
  47.                                     {
  48.                                         count++;
  49.                                     }
  50.                                     else if(a==c && b==d && b!=a)
  51.                                     {
  52.                                         count++;
  53.                                     }
  54.                                     else if(a==d && b==c && a!=c)
  55.                                     {
  56.                                         count++;
  57.                                     }
  58.                                 }
  59.                             }
  60.                         }
  61.                     }
  62.                 }
  63.             }
  64.         }
  65.         Console.WriteLine(count);
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement