Advertisement
Guest User

Untitled

a guest
Feb 4th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7.  
  8.  
  9. class Program
  10. {
  11.     static void Main(string[] args)
  12.     {
  13.         string number = Console.ReadLine();
  14.         BigInteger product = 1;
  15.         if (number.Length == 1)
  16.         {
  17.             Console.WriteLine(0);
  18.             Console.WriteLine(number);
  19.             return;
  20.         }
  21.         int numberLength = number.Length - 1;
  22.         long numberOfTransformations = 1;
  23.         long actualSum = 0;
  24.         bool whileToContinue = true;
  25.  
  26.         while (true)
  27.         {
  28.             if (numberLength <= 1)
  29.             {
  30.                 product *= number[0] - '0';
  31.                 number = product.ToString();
  32.                 numberLength = number.Length;
  33.                
  34.                 if (numberLength > 1)
  35.                 {
  36.                     numberLength--;
  37.                     whileToContinue = true;
  38.                    
  39.                     numberOfTransformations++;
  40.                     if (numberOfTransformations != 11)
  41.                     {
  42.                         product = 1;
  43.                     }
  44.                     else
  45.                     {
  46.                         Console.WriteLine(number);
  47.                         break;
  48.                     }
  49.                 }
  50.                 else
  51.                 {
  52.                     Console.WriteLine(numberOfTransformations);
  53.                     Console.WriteLine(number);
  54.                     whileToContinue = false;
  55.                     break;
  56.                 }
  57.             }
  58.  
  59.             else if (whileToContinue)
  60.             {
  61.                
  62.                 for (int i = 0; i < numberLength; i+= 2)
  63.                 {
  64.                     if (i % 2 == 0)
  65.                     {
  66.                         actualSum += number[i] - '0';
  67.  
  68.                     }
  69.  
  70.  
  71.                 }
  72.                 numberLength--;
  73.                 product *= actualSum;
  74.                 actualSum = 0;
  75.             }
  76.            
  77.            
  78.         }
  79.     }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement