ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1073. Square Country

How could we solve this problem by DP?
Posted by HowieMa 4 Mar 2017 19:10
We could solve it by Theorem on the sum of four squares, I wonder how to solve it by DP? If you know, please help me, thank you!
Re: How could we solve this problem by DP?
Posted by Mewtwo 4 Mar 2017 23:17
HowieMa wrote 4 March 2017 19:10
We could solve it by Theorem on the sum of four squares, I wonder how to solve it by DP? If you know, please help me, thank you!

Well...
For n=72... what are the possible squares you can take?
You can take 64,49,36,25...4,1 . So what's the best result for 72?
The best result Best(72)=min(Best(72-64),Best(72-49),Best(72-36), ... Best(72-1))+1;
Now whats the base cases? U see, for all square numbers, u can take it in one go.
So Best(1)=Best(4)=Best(9)=Best(16) ... = 1
Its a top down approach.
I hope u got the idea...
Goodluck.

Btw, I'm wondering how u solved by Theorem on the sum of four squares. Can u send your code to my mail please?
ealham86@gmail.com

Re: How could we solve this problem by DP?
Posted by abid1729 29 Mar 2020 14:23
i solved it with dp. but i wondered with u.plz send me ur code.
EMAIL:achowdhury@isrt.ac.bd