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 1066. Garland

why i keep getting WA??help
Posted by wangchun 25 Jul 2004 06:44
I've tried every tests i could found.
It's all right.
But i keep getting WA.
This is my program:

var t,n,l:integer;
    a:real;
    sz:array[1..1000]of record
                              x:integer;
                              n:real;
                        end;
    x,min,k:real;
    q:boolean;
begin
     readln(n,a);
     fillchar(sz,sizeof(sz),0);
     sz[1].n:=a;
     sz[2].x:=1;
     for t:=3 to n do
         begin
              sz[t].x:=sz[t-1].x*2-sz[t-2].x;
              sz[t].n:=(sz[t-1].n+1)*2-sz[t-2].n;
         end;
     min:=-1;
     for t:=2 to n-1 do
         begin
              x:=(-sz[t].n)/sz[t].x;
              q:=true;
              for l:=2 to n do
                  begin
                       k:=sz[l].x*x+sz[l].n;
                       q:=q and(k>=0);
                  end;
              k:=sz[n].x*x+sz[n].n;
              if ((k<min)or(min=-1))and(q) then
                 min:=k;
         end;
     writeln(min:0:2);
end.
Re: why i keep getting WA??help
Posted by Kopeliovitch Sergey (1) 25 Jul 2004 11:23
About your code: i don't know, sorry
About problem: there is simple solution O(1), about 12 strings...
Re: why i keep getting WA??help
Posted by The Cheater 25 Jul 2004 15:11
So can you tell the O(1) solution and if possible explain it ? Thank you.
Re: why i keep getting WA??help
Posted by Saturn 26 Jul 2004 09:38
My O(n) solution (I used maths)is 15 strings but I don't know there is a O(1) solution.Please explain it.