Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
DP水题,可以转化为背包做。var f:array[0..300,0..3]of longint; a:array[1..62]of longint; n,m,t,i,j,k:longint; begin for i:=1 to 20 do for j:=1 to 3 do begin inc(k); a[k]:=i*j; end; a[k+1]:=25; a[k+2]:=50; readln(n); for t:=1 to n do begin readln(m); writeln('Scenario #',t,':'); if m>180 then begin writeln(0); writeln; continue; end; fillchar(f,sizeof(f),0); f[0,0]:=1; for i:=1 to 62 do for j:=0 to m do for k:=0 to 2 do if f[j,k]>0 then inc(f[j+a[i],k+1],f[j,k]); writeln(f[m,0]+f[m,1]+f[m,2]+f[m,3]); if t<>n then writeln; end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator