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

Why i have WA #5
Posted by Terminator 29 Feb 2008 18:42
pleas tell me where is my mistake?

var n,q,a:longint;
begin
  read(n); q:=0;
   while n>=1 do
    begin
      a:=trunc(sqrt(n));
      a:=sqr(a); inc(q);
      n:=n-a;
    end;
   write(q);
end.
Re: Why i have WA #5
Posted by Boyan Lazov 15 Sep 2008 15:11
Shortly, this solution (greedy - take the biggest square size possible) is incorrect. For example, let's take 12. Your solution would take 9, 1, 1, 1 - 4 pieces. But you can distribute them 4, 4, 4 - 3 pieces