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 |
我用欧拉函数做,不知为何wrong answer(付代码)var n,total:longint; a:array[1..100] of longint; b:array[1..100] of longint; procedure work; var sum:double; i,j,m:longint; begin fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); m:=n;j:=0; for i:=2 to trunc(sqrt(n)) do begin if m mod i=0 then begin inc(j);a[j]:=i;while m mod i=0 do begin m:=m div i;inc(b[i]);end;end; end; if j=0 then total:=n-1 else begin sum:=n; for i:=1 to j do begin sum:=sum*(1-1/a[i]); end; total:=round(sum); end; end; begin readln(n); while n<>0 do begin work; writeln(total); readln(n); end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator