Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikola-Andreev/e5da3824ccf1ac0c90d6f338479a2690 to your computer and use it in GitHub Desktop.
Save Nikola-Andreev/e5da3824ccf1ac0c90d6f338479a2690 to your computer and use it in GitHub Desktop.
03.Target Multiplier
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Threading;
class Programa
{
static void Main(string[] args)
{
int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
long[,] matrix = new long[input[0], input[1]];
for (int row = 0; row < input[0]; row++)
{
int[] cells = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
for (int col = 0; col < input[1]; col++)
{
matrix[row, col] = cells[col];
}
}
int[] target = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
long sum = 0;
long min = Math.Max(target[0], 1);
long max = Math.Min(target[1], input[1] - 2);
sum += matrix[min - 1, max - 1];
matrix[min - 1, max - 1] *= matrix[target[0], target[1]];
sum += matrix[min - 1, max];
matrix[min - 1, max] *= matrix[target[0], target[1]];
sum += matrix[min - 1, max + 1];
matrix[min - 1, max + 1] *= matrix[target[0], target[1]];
sum += matrix[min, max - 1];
matrix[min, max - 1] *= matrix[target[0], target[1]];
sum += matrix[min, max + 1];
matrix[min, max + 1] *= matrix[target[0], target[1]];
sum += matrix[min + 1, max - 1];
matrix[min + 1, max - 1] *= matrix[target[0], target[1]];
sum += matrix[min + 1, max];
matrix[min + 1, max] *= matrix[target[0], target[1]];
sum += matrix[min + 1, max + 1];
matrix[min + 1, max + 1] *= matrix[target[0], target[1]];
matrix[target[0], target[1]] *= sum;
for (int row = 0; row < input[0]; row++)
{
for (int col = 0; col < input[1]; col++)
{
Console.Write(matrix[row,col]+" ");
}
Console.WriteLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment