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 |
水能告诉我为什么我的Pascal程序一直LTE(在机子上运行时很快)program ex; var a:array[2..431]of integer; b:array[0..100]of integer; c:array[0..431,0..83]of integer; d:array[0..431,0..431]of int64; i,j,k,t:integer; s:int64; begin fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); fillchar(c,sizeof(c),0); for i:=2 to 431 do if a[i]=0 then begin b[0]:=b[0]+1; b[b[0]]:=i; for j:=2 to 431 div i do a[i*j]:=1; end; d[0,0]:=1;d[1,0]:=1;d[1,1]:=1; for i:=2 to 431 do begin t:=i;j:=1; while t<>1 do begin if a[t]=0 then begin for k:=1 to b[0] do if b[k]=t then break; c[i,k]:=c[i,k]+1;j:=k+1;break;end; while t mod b[j]=0 do begin t:=t div b[j];c[i,j]:=c[i,j]+1;end; j:=j+1; end; for k:=1 to b[0] do c[i,k]:=c[i-1,k]+c[i,k]; for k:=b[0] downto 1 do if c[i,k]<>0 then begin c[i,0]:=k;break;end; for j:=0 to i div 2 do begin d[i,j]:=1; for k:=1 to b[0] do d[i,j]:=d[i,j]*(c[i,k]-c[j,k]-c[i-j,k]+1); end; end; while not(eof) do begin readln(i,j); if j>i div 2 then writeln(d[i,i-j]) else writeln(d[i,j]); end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator