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

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

is java's BigDecimal acceptable?
Послано Faeton (Kyiv - Mohyla Academy) 6 мар 2008 16:17
I solve reccurence, then pow to n(which takes log n to quickpow), but it's also TL.

How can i improve this not writing my own long arithmetic?
Re: is java's BigDecimal acceptable?
Послано elmariachi1414 (TNU) 29 мар 2008 01:21
It can be solved only with 2 divisions in BigDecimal, but answer length is about 32000 so [maybe] toString gives TLE on conversion binary data to decimal representation.
If somebody knows, how to solve this problem - please tell me
Re: is java's BigDecimal acceptable?
Послано bve 29 окт 2008 00:05
2^n = 10^(n*lg(2))
My AC solution:
int n0 = (int) (Math.log10(2f) * (n - 1));
int n1 = (int) (Math.log10(2f) * n);
int n2 = (int) (Math.log10(2f) * (n + 1));
int len = n1;
if (n1 == n2 && n1 == n0 + 1 && n % 2 != 0) {
  len = n0;
}

Answer is len.
Re: is java's BigDecimal acceptable?
Послано freedevc 4 ноя 2008 17:57
I thought that this problem's solution is :

t= (n-(n%10)) /4 +1
if(n>=30)
{
        t=t+1;
        x=n-n%10;
        if(n>39&&((x/10)%2)) t=t+(x-30)/20;
        if(n>49&&((n-n%10)%4==0)) t=t+(x-40)/20;
}
t= t+ (n%10)/4;
cout<<t;

but it got WA#8.

And i don't understand "if(n==1 && n1==n0+1 && n%2!=0)" statement are for what tests?
Would you mind explaining for me! Thanks!
Re: is java's BigDecimal acceptable?
Послано Artem Khizha [DNU] 31 окт 2010 23:24
bve, your way is brilliant.
Thank you!
Re: is java's BigDecimal acceptable?
Послано exwRabbits_AlMag(VNTU) 18 фев 2020 04:27
bve, any links to why it works?
Re: is java's BigDecimal acceptable?
Послано balatskayaolha 20 фев 2020 21:30
Thanks you!