← Back to topics
Topic

zasto stalno dobijam ovu poruku?

d
darkspirit
Izlazni kod nije 0
Evo primer


var i,j,l,n,m,pom,pomm:longint;
tt,t1,tpom:boolean;
br:integer;
used:array[1..4]of boolean;
t:array[1..30000]of boolean;
rez:array[1..4]of longint;


function p(x:integer):boolean;
begin
if (x=2) or (x=3) then p:=true else if x=4 then p:=false else
begin
tt:=true;
pomm:=1;
l:=0;
while tt do
begin
inc(pomm);
if (x mod pomm)=0 then begin inc(l); tt:=false; end;
if pomm>trunc(sqrt(x)) then tt:=false;
end;
if l>0 then p:=false else p:=true;
end;
end;




procedure stavi (w:longint);
var moze:boolean;
begin
if w>4 then
begin
if (br=0) and (w>60) then
begin
writeln(0);
inc(br) ;
end;
if (br=0) and (w<60) then
for i:=1 to 4 do writeln(rez[i]);
end
else if br=0 then
begin
t1:=false;
moze:=true;
for j:=n to m do
begin
moze:=true;
for i:=1 to w-1 do if j=rez[i] then moze:=false;
if w=1 then
begin rez[1]:=j; used[j]:=true;t1:=true ;stavi(2); end
else if moze then
begin
if p(j+rez[w-1])=false then
begin
rez[w]:=j;
used[j]:=true;
t1:=true;
stavi(w+1);
end;
end;
end;
if (t1=false) and (br=0) then
begin
if j<m then t1:=true;
end;

if (t1=false) and (w<5)and (br=0) then
begin
w:=65; tpom:=false; stavi(w);
end;
end;
end;



begin
readln(n,m);
br:=0;
for i:=n to m do t[i]:=false;

tpom:=true;

if m-n>=5 then
begin
for i:=n to m do
begin
if ((i mod 2)=0) and ((i mod 3)<>0) then
begin writeln(i); t[i]:=true; end;
end;

for i:=n to m do
begin
if ((i mod 2)=0) and ((i mod 3)=0) then
begin writeln(i); t[i]:=true; end;
end;

for i:=n to m do
begin
if ((i mod 3)=0) and (t[i]=false) then
begin writeln(i); t[i]:=true; end;
end;


for i:=n to m do
begin
if t[i]=false then writeln(i);
end;
end else

if m-n=1 then
begin
if p(m+n)=true then writeln(0) else begin writeln(n); writeln(m); end;
end else

if m-n=2 then
begin
if n mod 3=0 then
begin
for i:=n to m do if (i mod 3)=0 then writeln(i);
for i:=n to m do if (i mod 3)=2 then writeln(i);
for i:=n to m do if (i mod 3)=1 then writeln(i);
end else if m=3 then writeln(0) else
if n mod 3 =1 then
begin
for i:=n to m do if (i mod 3)=0 then writeln(i);
for i:=n to m do if (i mod 3)=1 then writeln(i);
for i:=n to m do if (i mod 3)=2 then writeln(i);
end else
if n mod 3 =2 then
begin
if (p(n+n+1)=false) and (p(n+1+n+2)=false) then begin writeln(n); writeln(n+1); writeln(n+2); end else
if (p(n+n+2)=false) and (p(n+2+n+1)=false) then begin writeln(n); writeln(n+2); writeln(n+1); end else
if (p(n+1+n)=false) and (p(n+n+2)=false) then begin writeln(n+1); writeln(n); writeln(n+2); end else
if (p(n+1+n+2)=false) and (p(n+2+n)=false) then begin writeln(n+1); writeln(n+2); writeln(n); end else
if (p(n+2+n)=false) and (p(n+n+1)=false) then begin writeln(n+2); writeln(n); writeln(n+1); end else
if (p(n+2+n+1)=false) and (p(n+1+n)=false) then begin writeln(n+2); writeln(n+1); writeln(n); end else
writeln(0);
end;

end else if m-n=4 then
begin
for i:=n to m do if (i mod 5)=0 then writeln(i);
for i:=n to m do if (i mod 5)=2 then writeln(i);
for i:=n to m do if (i mod 5)=4 then writeln(i);
for i:=n to m do if (i mod 5)=1 then writeln(i);
for i:=n to m do if (i mod 5)=3 then writeln(i);
end else if m-n=3 then
begin
for i:=n to m do used[i]:=false;
stavi(1);
end;
end.


b
boba5551
Nisam citao kod, ali postoji mogucnost da pokusavas da pristupis indexu niza koji je van opsega. Za koliko test primera ti prolazi?

P.S. Umesto
<pre>
if nesto = false then
</pre>
mozes koristiti
<pre>
if not nesto then
</pre>
d
darkspirit
Mislim da to nije problem. Isto se dogadja i sa ovom:

var u,n,m,x,y,k,odg:integer;
i,j:integer;
a:array[1..100,1..100]of integer;
begin
readln(n,m);
odg:=0;
for i:=1 to n do
begin
for j:=1 to n do
a[i,j]:=0;
end;
for u:=1 to m do
begin
readln(x,y,k);
for i:=x-k to x+k do
begin
if (i>0) and (i<n+1) then inc(a[i,y]);
end;

for i:=y-k to y+k do
begin
if (i>0) and (i<n+1) then inc(a[x,i]);
end;
dec(a[x,y]);
for i:=x-k+1 to x-1 do
begin
for j:=1 to i-x+k do
begin
if (i>0) and (y-j>0) and (i<n+1) then
inc(a[i,y-j]); if a[i,y-j]>odg then odg:=a[i,y-j];
if (i>0) and (i<n+1) and (y+j<n+1) then inc(a[i,y+j]);
if a[i,y+j]>odg then odg:=a[i,y+j];
end;
end;
for i:=x+1 to x+k-1 do
begin
for j:= k+x-i downto 1 do
begin
if (i>0) and (y-j>0) and (i<n+1) then
inc(a[i,y-j]); if a[i,y-j]>odg then odg:=a[i,y-j];
if (i>0) and (i<n+1) and (y+j<n+1) then inc(a[i,y+j]);
if a[i,y+j]>odg then odg:=a[i,y+j];
end;
end;
end;
writeln(odg);
end.


b
boba5551
Moje pitanje i dalje stoji! - na kom test primeru ti puca?
n
nemanja90
jel treba sacekati da se testira poslati zadatak i koliko?
jel su standardni ulaz i izlaz kad se cita iz datoteke(ako jesu, koji je naziv datoteke) ili sa user screen-a
b
boba5551
sa standardnog ulaza, sto znaci kao user da unosi
readln; read; cin; scanf...

kad posaljes zadatak, dobijas odmah da li je tacno ili nije ili cekas par sekundi ;)
m
matteo123
lijep kod na svu sreću ga kužim . samo koji zadatak
m
matteo123
e probaj ono šta staviš pod boolean ne stavljat u array jer šta će ti to . samo gubitak vremena .
stavi ovako
xxx:boolean
n
nemanja1990
Zasto ne bi stavljao array booleana ako mu je potreban?
m
matteo123
a sam mi reci koji zadatak
n
nemanja1990
Mene pitas? Otkud znam, kakve to veze ima?
m
matteo123
e a nigdje ti ne piše da to moraš pamtit
n
nemanja1990
Mislim da se nesto nismo razumeli. U svakom slucaju, glupo je da zatrpavamo forum ako nije nista bitno.

U svakom slucaju array of boolean moz da bude koristan a da li je u ovom primeru potreban, stvarno je nebitno.