fork download
  1. using System;
  2. using System.Numerics;
  3.  
  4. public static class ZadanieSpoj
  5. {
  6.  
  7. public static BigInteger Solution(int firstData, int secondData)
  8. => NumberOfCombinations(firstData - 1, secondData - 1);
  9.  
  10.  
  11. private static BigInteger NumberOfCombinations(int a, int b)
  12. {
  13. b = Math.Min(b, a - b);
  14. if (b == 0)
  15. return 1;
  16.  
  17. BigInteger result = a;
  18. for (int x = 2; x <= b; ++x)
  19. {
  20.  
  21. result *= a - x + 1;
  22. result /= x;
  23. }
  24.  
  25. return result;
  26. }
  27. }
  28.  
  29. public static class Program
  30. {
  31. private static void Main()
  32. {
  33. int temp = int.Parse(Console.ReadLine());
  34. while (temp-- > 0)
  35. {
  36. int[] line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
  37.  
  38. Console.WriteLine(
  39. ZadanieSpoj.Solution(line[0], line[1]));
  40. }
  41. }
  42. }
  43.  
  44.  
Success #stdin #stdout 0.03s 25408KB
stdin
2
10 10
30 7
stdout
1
475020