ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1209. 1, 10, 100, 1000...

Test #3 -Time limit exceeded (C#)
Послано Arantir 28 ноя 2011 03:06
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
Re: Test #3 -Time limit exceeded (C#)
Послано Reza 23 дек 2011 17:37
I don't know c# but I think it's correct.


why you don't use c++?
Re: Test #3 -Time limit exceeded (C#)
Послано PlayLinsor 14 авг 2013 15:52
Arantir писал(a) 28 ноября 2011 03:06
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 ");
            }


        }