Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- using System.Text;
- using System.Threading.Tasks;
- namespace Calculate_3
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int k = int.Parse(Console.ReadLine());
- //опитвам да раздробя формулата и да пресметна отделните ѝ части.
- BigInteger resultNFac = 1;
- BigInteger resultKFac = 1;
- BigInteger result = 0;
- BigInteger nMinusKFac = 1;
- if (1<k&&k<n&&n<100)
- {
- for (int i = 1; i <= n; i++)
- {
- //N! / (K! * (N - K)!)
- resultNFac *= i;
- if (i==k)
- {
- resultKFac = resultNFac;
- int nMinusK = n - k;
- for (int y = 1; y <= nMinusK; y++)
- {
- nMinusKFac *= y;
- }
- }
- }
- result = resultNFac / (resultKFac * nMinusKFac);
- Console.WriteLine(result);
- //Входни данни: 3 and 2 with result 3; 4 and 2 with res 6; 52 and 5 with res 2598960;
- //При въвеждане на посочения input програмата връща правилния отговор, но в judge системата има грешка при тест 10.
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement