BorislavBorisov

10.Lines - Наков

Sep 28th, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using System;
  2. class Lines
  3. {
  4.     static void Main()
  5.     {
  6.         int[,] matrix = new int[8,8];
  7.  
  8.         for (int row = 0; row < 8; row++)
  9.         {
  10.             int number = int.Parse(Console.ReadLine());
  11.             for (int col = 0; col < 8; col++)
  12.             {
  13.                 //int bits = number >> col & 1;
  14.                 //if(bits != 0){}matrix[row, col] =  1;
  15.                 matrix[row, col] = number >> col & 1;
  16.             }
  17.         }
  18.         int len = 0, bestLen = 0, count = 0;
  19.         for (int row = 0; row < 8; row++)
  20.         {
  21.             for (int col = 0; col < 8; col++)
  22.             {
  23.                 while (col < 8 && matrix[row, col] == 1)
  24.                 {
  25.                     len++;
  26.                     col++;
  27.                 }
  28.                 if (len == bestLen)
  29.                 {
  30.                     count++;
  31.                 }
  32.                 if(len > bestLen)
  33.                 {
  34.                     bestLen = len;
  35.                     count = 1;
  36.                 }
  37.                 len = 0;
  38.             }
  39.         }
  40.         for (int col = 0; col < 8; col++)
  41.         {
  42.             for (int row = 0; row < 8; row++)
  43.             {
  44.                 while (row < 8 && matrix[row, col] == 1)
  45.                 {
  46.                     len++;
  47.                     row++;
  48.                 }
  49.                 if (len == bestLen)
  50.                 {
  51.                     count++;
  52.                 }
  53.                 if (len > bestLen)
  54.                 {
  55.                     bestLen = len;
  56.                     count = 1;
  57.                 }
  58.                 len = 0;
  59.             }
  60.         }
  61.         if (bestLen == 1)
  62.         {
  63.             count = count / 2;
  64.         }
  65.         Console.WriteLine(bestLen);
  66.         Console.WriteLine(count);
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment