|
|
back to boardWhy i have WA #5 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 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 |
|
|