Advertisement
kon_simeonov

Untitled

Sep 13th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 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. namespace tester
  8. {
  9.  
  10.  
  11.     class Program
  12.     {
  13.        
  14.         static void Main(string[] args)
  15.         {
  16.             string input = Console.ReadLine();
  17.            
  18.             BigInteger evenSum = 0;
  19.             BigInteger product = 1;
  20.             int transformation = 0;
  21.  
  22.             while(transformation<10)
  23.             {
  24.                 product = 1;
  25.  
  26.                 while(input.Length>0)
  27.                 {
  28.                        
  29.                         input = input.Substring(0, input.Length - 1);
  30.                        
  31.                         int counter=0;
  32.                         for (int i = 0; i < input.Length; i += 2)
  33.                         {
  34.                             evenSum += input[i] - 48;
  35.                             counter++;
  36.                         }
  37.  
  38.                          if(counter>0)product *= evenSum;
  39.                         evenSum = 0;
  40.                    
  41.                 }
  42.                
  43.                
  44.                
  45.                 transformation++;
  46.                 input = product.ToString();
  47.                
  48.                 if (input.Length == 1)
  49.                     break;
  50.             }
  51.  
  52.             if(transformation<10)Console.WriteLine(transformation);
  53.             Console.WriteLine(product);
  54.            
  55.            
  56.  
  57.                
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement