milislavski

ConsoleApplication1

Apr 13th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.09 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 ConsoleApplication1
  10. {
  11.     static void Main(string[] args)
  12.     {
  13.         int count = 0;
  14.         BigInteger product = 1;
  15.         BigInteger finalProduct = 1;
  16.         BigInteger secondFinalProduct = 1;
  17.         var oddNumbers = new List<string>();
  18.         while (true)
  19.         {
  20.             string line = Console.ReadLine();
  21.             if (line == "END")
  22.             {
  23.                 break;
  24.             }
  25.             if (count % 2 != 0)
  26.             {
  27.                 oddNumbers.Add(line);
  28.             }
  29.             count++;
  30.         }
  31.         if (count <= 10)
  32.         {
  33.             for (int i = 0; i < oddNumbers.Count; i++)
  34.             {
  35.                 if (oddNumbers[i] == "0")
  36.                 {
  37.                     product *= 1;
  38.                 }
  39.                 else
  40.                 {
  41.                     for (int j = 0; j < oddNumbers[i].Length; j++)
  42.                     {
  43.                         if (oddNumbers[i][j] == '0')
  44.                         {
  45.                             continue;
  46.                         }
  47.                         else
  48.                         {
  49.                             product *= oddNumbers[i][j] - '0';
  50.                         }
  51.                     }
  52.                 }
  53.                 finalProduct *= product;
  54.                 product = 1;
  55.             }
  56.             Console.WriteLine(finalProduct);
  57.         }
  58.         else
  59.         {
  60.             for (int i = 0; i < 5; i++)
  61.             {
  62.                 if (oddNumbers[i] == "0")
  63.                 {
  64.                     product *= 1;
  65.                 }
  66.                 else
  67.                 {
  68.                     for (int j = 0; j < oddNumbers[i].Length; j++)
  69.                     {
  70.                         if (oddNumbers[i][j] == '0')
  71.                         {
  72.                             continue;
  73.                         }
  74.                         else
  75.                         {
  76.                             product *= oddNumbers[i][j] - '0';
  77.                         }
  78.                     }
  79.                 }
  80.                 finalProduct *= product;
  81.                 product = 1;
  82.             }
  83.             for (int i = 5; i < oddNumbers.Count; i++)
  84.             {
  85.                 if (oddNumbers[i] == "0")
  86.                 {
  87.                     product *= 1;
  88.                 }
  89.                 else
  90.                 {
  91.                     for (int j = 0; j < oddNumbers[i].Length; j++)
  92.                     {
  93.                         if (oddNumbers[i][j] == '0')
  94.                         {
  95.                             continue;
  96.                         }
  97.                         else
  98.                         {
  99.                             product *= oddNumbers[i][j] - '0';
  100.                         }
  101.                     }
  102.                 }
  103.                 secondFinalProduct *= product;
  104.                 product = 1;
  105.             }
  106.             Console.WriteLine(finalProduct);
  107.             Console.WriteLine(secondFinalProduct);
  108.         }
  109.     }
  110. }
Add Comment
Please, Sign In to add comment