Why it is so slowly??? I use standard formula with "sqrt(8*N-7)".
int L = int.Parse(Console.ReadLine());
string answer = "";
for (int i = 0; i < L; i++)
{
if (Math.Sqrt(8 * long.Parse(Console.ReadLine()) - 7) % 1 == 0) answer += "1 ";
else answer += "0 ";
}
Console.Write(answer);
I can't imagine shortest solution... What's the matter?
Many people has used C# successful in problem 1209.
Edited by author 28.11.2011 03:09
Compare with this code
static void Main(string[] args)
{
int len = int.Parse(Console.ReadLine());
int[] mas = new int[len];
int max = 0;
for (int f = 0; f < len; f++)
{
mas[f] = int.Parse(Console.ReadLine());
if (mas[f] > max) max = mas[f];
}
foreach (long i in mas)
{
double ig = (Math.Sqrt(8*i-7))%1;
if (ig == 0) Console.Write("1 ");
else Console.Write("0 ");
}
}