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 1032. Find a Multiple

Why didi I get 'Compilation error'?
Posted by 123789 23 Nov 2007 10:00
I can run it in FP,but if I put it on,it will showed'Compilation error'.
Who can tell me why?

var
  n,i,j,t,l:longint;
  a:array[0..1000] of longint;
  c:array[0..1000] of boolean;
  f:array[0..50000,0..1000] of boolean;
begin
   readln(n);
   for i:=1 to n do readln(a[i]);
   c[0]:=true;f[0,0]:=true;
   for i:=1 to n do
   for j:=n downto a[i] do
    if c[j-a[i]] then begin
    c[j]:=true;

   for l:=0 to i-1 do

    if f[j-a[i],l] then
   f[j,l]:=true;
   f[j,i]:=true;
   if j=n then begin
   for i:=1 to i do
   if f[n,i] then inc(t);
   writeln(t);
   for i:=1 to i do
   if f[n,i] then writeln(a[i]);halt;
   end;
   end;
   writeln(0);
end.
Re: Why didi I get 'Compilation error'?
Posted by KIRILL(ArcSTUpid coder:) 23 Nov 2007 15:56
var
n,i,j,t,l:longint;
a:array[0..1000] of longint;
c:array[0..1000] of boolean;
f:array[0..50000,0..1000] of boolean;
begin
readln(n);
for i:=1 to n do readln(a[i]);
c[0]:=true;f[0,0]:=true;
for i:=1 to n do           //If you use var i here
for j:=n downto a[i] do
if c[j-a[i]] then begin
c[j]:=true;

for l:=0 to i-1 do

if f[j-a[i],l] then
f[j,l]:=true;
f[j,i]:=true;
if j=n then begin
for i:=1 to i do            // then you can not use it inside cycle
if f[n,i] then inc(t);
writeln(t);
for i:=1 to i do
if f[n,i] then writeln(a[i]);halt;
end;
end;
writeln(0);
end.

You can choose "send reply on my email" for explanations

Edited by author 23.11.2007 15:59
Re: Why didi I get 'Compilation error'?
Posted by garfield 26 Nov 2007 17:20
Thanks a lot