Day i do not know
This commit is contained in:
11
231. Power of Two/231. Power of Two.csproj
Normal file
11
231. Power of Two/231. Power of Two.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>_231._Power_of_Two</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
9
231. Power of Two/Program.cs
Normal file
9
231. Power of Two/Program.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace _231._Power_of_Two;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(new Solution().IsPowerOfTwo(int.Parse(Console.ReadLine()!)));
|
||||
}
|
||||
}
|
||||
10
231. Power of Two/Solution.cs
Normal file
10
231. Power of Two/Solution.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace _231._Power_of_Two;
|
||||
|
||||
public class Solution
|
||||
{
|
||||
public bool IsPowerOfTwo(int n)
|
||||
{
|
||||
double log = Math.Log(n, 2);
|
||||
return Math.Round(log, 12) == (int)log;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user