|
|
back to boardWhat's wrong Help me PLEASE! What's wrong with it? I always get WA. program timus_1021; var t1, t2:array [1..50000] of longint; j, i, l1, l2, l:longint; wyn:boolean; begin readln (l1); for i:=1 to l1 do readln (t1[i]); readln (l2); for i:=1 to l2 do readln (t2[i]); i:=0; wyn:=false; repeat inc (i); j:=l2; while t1[i]+t2[j]<10000 do dec (j); if t1[i]+t2[j]=10000 then wyn:=true; until i=l1; if wyn then writeln ('YES') else writeln ('NO') end. Re: What's wrong Posted by Sashko 14 Mar 2003 20:33 > Help me PLEASE! > What's wrong with it? > I always get WA. > while t1[i]+t2[j]<10000 do > dec (j); > if t1[i]+t2[j]=10000 then wyn:=true; ... Did you sort the sequence ? No You didn't, So why do You expect that after "t1[i]+t2[j]<10000" can't be "t1[i]+t2[j]>10000" and then "t1[i]+t2[j]<10000" again ? You must either sort the arrays before, or change the condition in "while", to check ALL combinations. Re: what is my problem in here you can give tests Posted by zzzlll 3 Jan 2007 17:09 var say,say2:array [1..10000] of integer; n,k,i,m,s:longint; begin s:=0; readln(n); repeat k:=k+1; readln(say[k]); until k=n; readln(m); repeat i:=i+1; readln(say2[i]); until i=m; i:=0; k:=0; repeat k:=k+1; repeat i:=i+1; if (say[k]+say2[i])=10000 then s:=1; until s=1; until s=1; if s=1 then writeln('yes') else writeln('no'); end. |
|
|