Advertisement
dimitarbogdanov

Комплекти

Nov 26th, 2022
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System.Runtime.CompilerServices;
  2.  
  3. class Solution
  4. {
  5.     [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
  6.     private static ulong Fact(ulong n)
  7.     {
  8.         ulong ret = 1;
  9.         for (ulong i = 1; i <= n; i++)
  10.         {
  11.             ret *= i;
  12.         }
  13.         return ret;
  14.     }
  15.  
  16.     [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
  17.     private static ulong C(ulong n, ulong r) => Fact(n) / (Fact(r) * Fact(n - r));
  18.  
  19.     public static void Main()
  20.     {
  21.         int tests = Int32.Parse(Console.ReadLine()!);
  22.         for (int testNo = 0; testNo < tests; testNo++)
  23.         {
  24.             ulong[] input = Console.ReadLine()!.Split(' ', 4).Select(UInt64.Parse).ToArray();
  25.             Console.WriteLine(C(input[2], input[0]) * C(input[3], input[1]));
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement