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

Обсуждение задачи 1605. Дьявольская последовательность

HELP WITH IDEA!!!
Послано Nurbek_[KTMU MANAS] 3 мар 2008 13:33
Who has accepted this task, please help with idea.
I have not anithing idea!
Re: HELP WITH IDEA!!!
Послано svr 3 мар 2008 13:43
Use log10 to compare 2^n and 10^k
Re: HELP WITH IDEA!!!
Послано Nurbek_[KTMU MANAS] 3 мар 2008 13:53
2 svr: I don't understand what you mean ? What I should use
formule or ...?
Re: HELP WITH IDEA!!!
Послано alex zaharov 3 мар 2008 14:14
This sequence representable in the form of partial sums apparent number, the amount of which is equal to 1 / 6 - to find the desired response should compare the full amount of partial, asked n. only math.
--
по-русски:
эта последовательность представима в виде частичных сумм очевидного ряда, сумма которого равна 2/3 - чтобы найти искомый ответ необходимо сравнить всю сумму с частичной, задаваемой n. чистая математика.
Re: HELP WITH IDEA!!!
Послано Nurbek_[KTMU MANAS] 3 мар 2008 16:06
Thanks a lot!!!
Re: HELP WITH IDEA!!!
Послано Vedernikoff Sergey 3 мар 2008 16:31
I've accepted this problem using precalc. Just quick long arithmetics and some trick to make source file of size 4 Kb...
Re: HELP WITH IDEA!!!
Послано svr 3 мар 2008 20:45
I meant the formula
a[n]=2/3+(-1)^(n-1)/(3*2^(n-1))
Re: HELP WITH IDEA!!!
Послано vgu 5 мар 2008 02:27
to svr:
you are right, this formula is correct (I can prove it).
But how to take benefit from this?
Of course, using this this formula I can right brute force quick long arithmetics. But this algo will be TL.
Re: HELP WITH IDEA!!!
Послано KIRILL(ArcSTUpid coder:) 5 мар 2008 03:07
we should take log10 from abs(2/3-a[n]) ??
Re: HELP WITH IDEA!!!
Послано svr 5 мар 2008 10:16
use also the formula:
2/3=0.666666+10^(-k)*2/3
Re: HELP WITH IDEA!!!
Послано SkorKNURE 29 окт 2010 05:38
I think problem is very interesting. I was trying to solve it in "programming way" for a long time, but all my attempts lead to TL on N > 10000 values. Finally I finished with completely mathematical solution. I think that description from my source can help someone so I'll left it here...

/*
 * Let x[n] be n-th element of given sequence.
 * Following formula for x[n] can be simply proved:
 *    x[n] = 2/3 + (1/3)/(2^(n-1)) if n - odd
 *    x[n] = 2/3 - (1/3)/(2^(n-1)) if n - even
 * Let delta = (1/3)/(2^(n-1)) = 0.000XXXX.. (X - any digit)
 * We can simply find number of leading zeroes after
 * decimal point (befor XXX..) as:
 *    k = floor[ Log10(3*2^(n-1)) ] or
 *    k = floor[ Log10(3) + (n-1)*Log10(2) ]
 * Obviously answer always will be k or k-1.
 * Consider (k-1)-cases:
 * [1] N - odd (add delta):
 *     A = (1/3)/(10^k) = 0.0003333... (repeat 0 k times)
 *     If A <= delta - then addition will affect k-th digit
 *     and answer will be k-1.
 * [2] N - even (subtract delta):
 *     A = (2/3)/(10^k) = 0.0006666... (repeat 0 k times)
 *     If A <= delta - then subtraction will affect k-th digit
 *     and answer will be k-1.
 * Compare logarithms instead of comparing values themself.
 */