GetTumblerStatus.cs

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static int GetTumblerStatus(int n)
	{
		if (n <= 0)
		{
			throw new Exception("N should be greater than 0!");
		}
		
		int sqrt = (int)Math.Sqrt(n);
		
		// Если N - полный квадрат, выводим 1, иначе 0.
		return sqrt * sqrt == n ? 1 : 0;
	}	
	
	public static void Main()
	{
		Console.WriteLine("UniLecs");
		Console.WriteLine(string.Format("Answer = {0}", GetTumblerStatus(1))); // 1
		Console.WriteLine(string.Format("Answer = {0}", GetTumblerStatus(5))); // 0
	}
}
;