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

Обсуждение задачи 1073. Квадратная страна

Help!!!!!!!
Послано Charlie 28 июл 2006 19:58
Who can help me!!!tell me how to solve the problem!!!
Re: Help!!!!!!!
Послано sniper 4 сен 2006 17:56
DP:
a[i]:=min(a[i-j*j])+1
j:=trunc(sqrt(i div 4)+1)to trunc(sqrt(i))
Re: Help!!!!!!!
Послано Charlie 8 сен 2006 20:05
thank u!nou I get AC.
BUT WHY
Послано SM 9 янв 2007 10:55
can anyone tell me why (sqrt(i div 4)+1)?
Re: Help!!!!!!!
Послано xerxe 14 янв 2007 21:31
You don't need DP. You can solve it in O(1).
Well actually, O(7) at worst :).
I didn't solve it yet, I have WA at test 5, but I'm sure it can be done.

[Edit] The algo is:
read n
while n>0
 x++
 n-=(int(sqrt(n)))^2
write x
[/Edit]
P.S: still have WA @ #5 :(. Don't know why...

Edited by author 14.01.2007 23:09
Re: Help!!!!!!!
Послано xerxe 23 янв 2007 15:45
Ok, my bad ... You need DP. Greedy is bad ! I need to remember that... Thanx to the guy who posted the 181 case.
Re: Help!!!!!!!
Послано Slam [Tartu U] 24 янв 2007 11:00
Actually, u don't need DP ) didt u read other topics?-)
Re: BUT WHY
Послано alisher 17 фев 2007 12:02
because there are 4 sides at the square!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Re: Help!!!!!!!
Послано jagatsastry 2 дек 2007 18:10
What does "i" refer to. Can anyone tell me How the above method works. i.e. what a[i] stores.
?
Послано CHIDEMYAN SERGEY 2 дек 2007 21:19
[deleted]

Edited by author 16.12.2008 18:48
Re: Help!!!!!!!
Послано Bobur 25 дек 2007 22:10
thank u very much, i've AC wiht your help
Re: Help!!!!!!!
Послано Cyclops 22 авг 2008 10:33
how could you get the transition function (a[i]:=min(a[i-j*j])+1)? How could you find it? Is it a "try -error method?" Please explain to me..thanks..
Re: Help!!!!!!!
Послано xerxe 12 май 2009 01:39
I did, but didn't understand them yet. (yes, I'm still at it after two years!)
Re: Help!!!!!!!
Послано partisan 10 июн 2009 15:58
Greedy fails on 12:
12=9+1+1+1 (greedy)
12=4+4+4 (correct)
WA #5
Послано Volkov Stanislav [MSU_Tashkent] 15 авг 2011 22:29


Edited by author 15.08.2011 22:30