iliya87

04.WinningNumbers

Mar 27th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         string input = Console.ReadLine().ToLower();
  8.         int letSum = 0;
  9.  
  10.         for (int i = 0; i < input.Length; i++)
  11.         {
  12.             letSum += input[i] - 'a' + 1;
  13.         }
  14.        int counter = 0;
  15.         for (int digit1 = 1; digit1 <= 9; digit1++)
  16.         {
  17.             for (int digit2 = 1; digit2 <= 9; digit2++)
  18.             {
  19.                 for (int digit3 = 1; digit3 <= 9; digit3++)
  20.                 {
  21.                     if (digit1 * digit2 *digit3 == letSum)
  22.                     {
  23.                         for (int digit4 = 1; digit4 <= 9; digit4++)
  24.                         {
  25.                             for (int digit5 = 1; digit5 <= 9; digit5++)
  26.                             {
  27.                              for (int digit6 = 1; digit6 <= 9; digit6++)
  28.                                 {
  29.                                         if (digit4*digit5*digit6  == letSum)
  30.                                             {
  31.                                             Console.WriteLine("{0}{1}{2}-{3}{4}{5}"
  32.                                                 ,digit1,digit2,digit3,digit4,digit5,digit6);
  33.                                             counter++;
  34.                                             }
  35.                                 }  
  36.                             }
  37.                         }
  38.                     }
  39.                 }
  40.              
  41.             }
  42.          
  43.         }
  44.         if (counter == 0)
  45.         {
  46.             Console.WriteLine("No");
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment