Advertisement
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;
- namespace _02BunnyFactory
- {
- class Program
- {
- static void Main()
- {
- List<int> input = new List<int>();
- string line = Console.ReadLine();
- while (line != "END")
- {
- input.Add(int.Parse(line));
- line = Console.ReadLine();
- }
- input.Reverse();
- //for (int cages = input.Count - 1; cages >= 0; cages--)
- //{
- // if (shouldBreak)
- // {
- // break;
- // }
- for (int process = 1; process < input.Count; process++)
- {
- int sum = 0;
- int s = 0;
- BigInteger product = 1;
- for (int i = input.Count - 1; i >= input.Count - process; i--)
- {
- sum += input[i];
- }
- if (input.Count < sum + process)
- {
- break;
- }
- for (int step = input.Count - process - 1; step >= input.Count - process - sum; step--)
- {
- s += input[step];
- product *= input[step];
- }
- input.RemoveRange(input.Count - process - sum, process + sum);
- do
- {
- int remainder = (int)(product % 10);
- if (remainder != 0 && remainder != 1)
- {
- input.Add(remainder);
- }
- product /= 10;
- }
- while (product > 0);
- do
- {
- int remainder = s % 10;
- if (remainder != 0 && remainder != 1)
- {
- input.Add(remainder);
- }
- s /= 10;
- }
- while (s > 0);
- do
- {
- input.Remove(1);
- }
- while (input.Contains(1));
- do
- {
- input.Remove(0);
- }
- while (input.Contains(0));
- }
- //}
- input.Reverse();
- for (int i = 0; i < input.Count; i++)
- {
- Console.Write(input[i] + " ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement