using System; using System.Collections.Generic; using System.Linq; // https://yukicoder.me/problems/no/1591 class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("5"); //2 } else if (InputPattern == "Input2") { WillReturn.Add("6"); //0 } else if (InputPattern == "Input3") { WillReturn.Add("25"); //4 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); long N = long.Parse(InputList[0]); var HeihousuuSet = new HashSet(); for (long I = 1; I * I <= N * N; I++) { HeihousuuSet.Add(I * I); } long Answer = 0; foreach (long EachVal in HeihousuuSet) { long Rest = N * N - EachVal; if (HeihousuuSet.Contains(Rest)) { Answer++; } } Console.WriteLine(Answer); } }