1 solutions
-
0
Pascal :
var n:array[1..2,0..10000] of longint; s,x,j,m:longint; procedure f(s,i:longint); begin if s-n[1,i]=0 then begin n[2,i]:=1; for j:=1 to x do if n[2,j]=1 then writeln('number:',j,' ','weight:',n[1,j]); halt; end; if(s<0) or (i<=0) or ((s>0) and (i=0)) then exit; n[2,i]:=1; f(s-n[1,i],i-1); n[2,i]:=0; f(s,i-1); end; begin readln(x,s); for j:=1 to x do begin read(m); n[1,j]:=m; end; f(s,x); write('not found'); end.
- 1
Information
- ID
- 16750
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By