Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Program
- {
- public static void Main()
- {
- string[] r = Console.ReadLine().Split(' ');
- int n = int.Parse(r[0]), m = int.Parse(r[1]);
- int[,] a = new int[n, m];
- for (int i = 0; i < n; i++)
- {
- int[] b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- for (int j = 0; j < m; j++)
- a[i, j] = b[j];
- }
- int s1, s2, s3, s4;
- s1 = s2 = s3 = s4 = 0;
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++)
- {
- if (i == j)
- s1 += a[i, j];
- if (i + j == n - 1)
- s2 += a[i, j];
- if (i < j)
- s3 += a[i, j];
- if (i > j)
- s4 += a[i, j];
- }
- if (s1 == s2 && s3 % 2 == 0 && s4 % 2 != 0)
- {
- s1 = s2 = s3 = s4 = 0;
- for (int i = 0; i < n; i++)
- for (int j = 0; j < m; j++)
- {
- if (i > j)
- s1 += a[i, j];
- if (i == j && a[i, j] % 2 == 0)
- s2 += a[i, j];
- if (((i == 0) || (i == n - 1)) && (a[i, j] % 2 == 0))
- s3 += a[i, j];
- if (((j == 0) || (j == m - 1)) && (a[i, j] % 2 != 0))
- s4 += a[i, j];
- }
- Console.WriteLine("YES\nThe amount of money won is: {0:0.00}", Math.Round((s1+s2+s3+s4)/4.0,2));
- }
- else
- Console.WriteLine("NO");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement