Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- //read input data
- byte[] numbers = new byte[8];
- for (int i = 0; i < 8; i++)
- {
- numbers[i] = byte.Parse(Console.ReadLine());
- }
- //some variables to store data
- byte currentLine = 0;
- byte longestLine = 0;
- byte longestLineCount = 0;
- //check lines in colums
- for (int col = 0; col < 8; col++)
- {
- for (int i = 0; i < 8; i++)
- {
- byte mask = (byte)((numbers[i] >> col) & 1);
- if (mask == 1) currentLine++;
- if (mask == 0 | i == 7)
- {
- if (currentLine == longestLine) longestLineCount++;
- if (currentLine > longestLine)
- {
- longestLine = currentLine;
- longestLineCount = 1;
- currentLine = 0;
- }
- currentLine = 0;
- }
- }
- }
- //check lines in rows
- for (int row = 0; row < 8; row++)
- {
- for (int i = 0; i < 8; i++)
- {
- byte mask = (byte)((numbers[row] >> i) & 1);
- if (mask == 1) currentLine++;
- if (mask == 0 | i == 7)
- {
- if (currentLine == longestLine) longestLineCount++;
- if (currentLine > longestLine)
- {
- longestLine = currentLine;
- longestLineCount = 1;
- currentLine = 0;
- }
- currentLine = 0;
- }
- }
- }
- if (longestLine == 1) longestLineCount = (byte)(longestLineCount / 2);
- Console.WriteLine(longestLine);
- Console.WriteLine(longestLineCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement