解题思路: 首先用筛数法把 50000 以内的质数筛出来,然后用循环求出它最小的质数因数,再用读入的 n 除以这个数即是答案。 程序: const maxn=50000; var f:array[1..maxn] of boolean; n,i,j:longint; begin readln(n); fillchar(f,sizeof(f),true); for i:=2 to trunc(sqrt(maxn)) do if f[i] then for j:=2 to maxn div i do f[i*j]:=false; for i:=2 to maxn do if f[i]and(n mod i=0) then begin writeln(n div i); halt; end; end. 版权属于: Chris 原文地址: http://blog.sina.com.cn/s/blog_83ac6af80102v5ow.html 转载时必须以链接形式注明原始出处及本声明。