Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- using System.Threading;
- public class MagicCarNumbers
- {
- public static void Main()
- {
- Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- checked
- {
- int magicWeight = int.Parse(Console.ReadLine());
- int magicCarNums = 0;
- if (magicWeight >= 60)
- {
- char[] carLetters = { 'A', 'B', 'C', 'E', 'H', 'K', 'M', 'P', 'T', 'X' };
- int[] weightLetters = { 10, 20, 30, 50, 80, 110, 130, 160, 200, 240 };
- magicWeight -= 40;
- for (int a = 0; a < 10; a++)
- {
- for (int b = 0; b < 10; b++)
- {
- for (int c = 0; c < 10; c++)
- {
- for (int d = 0; d < 10; d++)
- {
- bool digitsIsMagic = (b == a && c == a && d == a) || (c == b && d == b)
- || (b == a && c == a) || (b == a && d == c) || (c == a && d == b)
- || (d == a && c == b);
- if (digitsIsMagic)
- {
- int sumDigits = a + b + c + d;
- for (int x = 0; x < carLetters.Length; x++)
- {
- for (int y = 0; y < carLetters.Length; y++)
- {
- int sumLetters = weightLetters[x] + weightLetters[y];
- if (sumDigits + sumLetters == magicWeight)
- {
- magicCarNums++;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- Console.WriteLine(magicCarNums);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement