ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1356. Something Easier

What is wrong? Way WA on test 1?
Posted by ss 29 Mar 2005 18:07
|var t:longint;
|    x,i,a,b,c,len:longint;
|    ar:array[1..11000]of longint;
|
|
|function simple(x:longint):boolean;
|var i:integer;
|begin
|  if x=1 then begin simple:=false; exit; end;
|  for i:=2 to trunc(sqrt(x))do
|    if x mod i =0 then begin
|      simple:=false;
|      exit
|    end;
|  simple:=true;
|end;
|
|procedure razb(x:longint;var a,b,c:longint);
|var i,j,k:longint;
|begin
|  j:=1;
|  i:=1;
|  while (ar[i]<=x) and (i<=len) do begin
|    j:=i;
|    while (ar[j]<=x)and (j<=len) do begin
|      if x-ar[i]-ar[j]>=0 then
|         if simple(x-ar[i]-ar[j]) then begin
|            a:=ar[i];
|            b:=ar[j];
|            c:=x-ar[i]-ar[j];
|          if(a=0) or(b=0) or(c=0) then begin
|            a:=ar[i];
|            b:=ar[j];
|            c:=x-ar[i]-ar[j];
|            exit;
|          end
|        end;
|        inc(j);
|       end;
|    inc(i);
|  end;
|end;
|
|
|begin
|  t:=1;
|  for i:=2 to 100000 do
|    if simple(i) then begin
|      ar[t]:=i;
|      inc(t);
|    end;
|  len:=t;