Day i do not know

This commit is contained in:
Electrominch
2022-10-18 00:45:31 +03:00
parent 01c5720116
commit 284b6ff10c
72 changed files with 1256 additions and 12 deletions

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>_62._Unique_Paths</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,9 @@
namespace _62._Unique_Paths;
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine(new Solution().UniquePaths(10,10));
}
}

View File

@@ -0,0 +1,29 @@
using System.Numerics;
namespace _62._Unique_Paths;
public class Solution
{
public int UniquePaths(int min, int max)
{
min--;
max--;
if (min == 0 || max == 0)
return 1;
if(min > max)
{
min = min + max;
max = min - max;
min = min - max;
}
return (int)(Fact(max + 1, min + max) / Fact(1, min));
}
private BigInteger Fact(int start, int end)
{
BigInteger res = start;
while (++start <= end)
res *= start;
return res;
}
}