Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- class ConsoleApplication1
- {
- static void Main(string[] args)
- {
- int count = 0;
- BigInteger product = 1;
- BigInteger finalProduct = 1;
- BigInteger secondFinalProduct = 1;
- var oddNumbers = new List<string>();
- while (true)
- {
- string line = Console.ReadLine();
- if (line == "END")
- {
- break;
- }
- if (count % 2 != 0)
- {
- oddNumbers.Add(line);
- }
- count++;
- }
- if (count <= 10)
- {
- for (int i = 0; i < oddNumbers.Count; i++)
- {
- if (oddNumbers[i] == "0")
- {
- product *= 1;
- }
- else
- {
- for (int j = 0; j < oddNumbers[i].Length; j++)
- {
- if (oddNumbers[i][j] == '0')
- {
- continue;
- }
- else
- {
- product *= oddNumbers[i][j] - '0';
- }
- }
- }
- finalProduct *= product;
- product = 1;
- }
- Console.WriteLine(finalProduct);
- }
- else
- {
- for (int i = 0; i < 5; i++)
- {
- if (oddNumbers[i] == "0")
- {
- product *= 1;
- }
- else
- {
- for (int j = 0; j < oddNumbers[i].Length; j++)
- {
- if (oddNumbers[i][j] == '0')
- {
- continue;
- }
- else
- {
- product *= oddNumbers[i][j] - '0';
- }
- }
- }
- finalProduct *= product;
- product = 1;
- }
- for (int i = 5; i < oddNumbers.Count; i++)
- {
- if (oddNumbers[i] == "0")
- {
- product *= 1;
- }
- else
- {
- for (int j = 0; j < oddNumbers[i].Length; j++)
- {
- if (oddNumbers[i][j] == '0')
- {
- continue;
- }
- else
- {
- product *= oddNumbers[i][j] - '0';
- }
- }
- }
- secondFinalProduct *= product;
- product = 1;
- }
- Console.WriteLine(finalProduct);
- Console.WriteLine(secondFinalProduct);
- }
- }
- }
Add Comment
Please, Sign In to add comment