-
-
Save unilecs/62f77200f629196ddd0e574cb5d9bc32 to your computer and use it in GitHub Desktop.
Задача: Детский утренник
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program | |
{ | |
private static int GetSamePositionsByPermutation(int n, int m) | |
{ | |
int[,] arr1 = new int[n, m]; | |
int[,] arr2 = new int[n, m]; | |
for (int i = 0; i < n; i++) | |
{ | |
for (int j = 0; j < m; j++) | |
{ | |
arr1[i, j] = i * m + j + 1; | |
arr2[i, j] = j * n + i + 1; | |
} | |
} | |
int count = 0; | |
for (int i = 0; i < n; i++) | |
{ | |
for (int j = 0; j < m; j++) | |
{ | |
if (arr1[i, j] == arr2[i, j]) | |
{ | |
count++; | |
} | |
} | |
} | |
return count; | |
} | |
public static void Main() | |
{ | |
Console.WriteLine("UniLecs"); | |
Console.WriteLine(string.Format("Answer = {0}", GetSamePositionsByPermutation(3, 3))); // 2 | |
Console.WriteLine(string.Format("Answer = {0}", GetSamePositionsByPermutation(3, 4))); // 3 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment