const fin = 'prime1032.inp'; fon = 'prime1032.out'; var p:array[1..2000000] of byte; a:array[1..1000000] of longint; m,n,b,i,j,max,d:longint; function ktnt(n:int64):boolean; var i:longint; begin if n<2 then exit(false); if (n=2) or (n=3) then exit(true); for i:=2 to trunc(sqrt(n)) do if n mod i = 0 then exit(false); exit(true); end; procedure sang; var i,j:longint; begin p[1]:=1; for i:=2 to trunc(sqrt(b)) do if p[i]=0 then begin j:=i*i; while j<=b do begin p[j]:=1; j:=j+i; end; end; end; procedure tao_mang_nt; var i:longint; begin d:=0; for i:=1 to b do if p[i]=0 then begin inc(d); a[d]:=i; end; end; begin assign(input,fin);reset(input); assign(output,fon);rewrite(output); read(n); b:=trunc(sqrt(n)); sang; tao_mang_nt; max:=0; for i:=1 to d do begin for j:=n div a[i] downto a[i+1] do if ktnt(j) = true then begin if a[i]*j>max then max:=a[i]*j; break; end; end; write(max); close(input);close(output); end.
* Chuyên dạy lập trình ONLINE cho học sinh THCS, THPT *.
Mọi giao lưu, trao đổi, xin liên hệ: Lê Quang Vinh - zalo: 037.803.8755.
Page: Lớp học Code Sky
Group FB1: Ôn thi HSG9 - THTB - TS10 chuyên tin
Group FB2: Học Scratch - Ôn thi Tin học trẻ bảng A
Thứ Ba, 3 tháng 5, 2022
PRIME1032 PAS
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét
Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.