Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class NeuronMapping
- {
- static void Main()
- {
- List<uint> stackOfNumber = new List<uint>();
- uint currentNumber = 0;
- while (uint.TryParse(Console.ReadLine(), out currentNumber))
- {
- stackOfNumber.Add(currentNumber);
- }
- int rowSize = stackOfNumber.Count;
- int colSize = 32;
- int currentCountBits = 0;
- string[,] matrix = new string[rowSize, colSize];
- for (int row = 0; row < rowSize; row++)
- {
- currentCountBits = 0;
- currentNumber = stackOfNumber[row];
- for (int col = 0; col < colSize; col++)
- {
- matrix[row, colSize - 1 - col] = (currentNumber & 1).ToString();
- currentNumber >>= 1;
- }
- }
- string convertedBits = string.Empty;
- bool canIWriteInMatrix = false;
- bool oneInput = true;
- int colWithOnes = 0;
- for (int row = 0; row < rowSize; row++)
- {
- convertedBits = new string('0', 32);
- canIWriteInMatrix = false;
- oneInput = true;
- for (int col = 0; col < colSize; col++)
- {
- if (col + 1 < colSize && matrix[row, col] == "1" && matrix[row, col + 1] == "0" )
- {
- if (oneInput)
- {
- convertedBits = string.Empty;
- colWithOnes = col;
- oneInput = false;
- }
- for (int i = 0; i < colSize ; i++)
- {
- if (canIWriteInMatrix == false && (i > colWithOnes) && (i+1 < colSize) && ((matrix[row, i + 1] == "0" && matrix[row, i] == "1") || (matrix[row, i] == "1" && matrix[row, i + 1] == "1")))
- {
- canIWriteInMatrix = true;
- }
- if (i <= colWithOnes || canIWriteInMatrix)
- {
- convertedBits += "0";
- }
- else
- {
- convertedBits += "1";
- }
- }
- if (canIWriteInMatrix)
- {
- for (int colWriter = 0; colWriter < colSize; colWriter++)
- {
- matrix[row, colWriter] = convertedBits[colWriter].ToString();
- }
- }
- else
- {
- convertedBits = new string('0', 32);
- for (int colWriter = 0; colWriter < colSize; colWriter++)
- {
- matrix[row, colWriter] = convertedBits[colWriter].ToString();
- }
- }
- break;
- }
- }
- }
- uint sum = 0;
- for (int row = 0; row < rowSize; row++)
- {
- for (int col = 0; col < colSize; col++)
- {
- sum |= (uint.Parse(matrix[row,colSize - 1 - col]) & 1) << col;
- }
- Console.WriteLine(sum);
- sum = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement