procedure nhap;
begin
read(k);
end;
function ktnt(x:int64):boolean;
var i:longint;
begin
if x<2 then exit(false);
for i:=2 to trunc(sqrt(x)) do
if x mod i=0 then exit(false);
exit(true);
end;
procedure sang;
var i,j:longint;
begin
m:=0;
for i:=1 to max do p[i]:=true;
p[1]:=false;
for i:=2 to trunc(sqrt(max)) do
begin
if (p[i]=true) then
begin
j:=i+i;
while j<=max do
begin
p[j]:=false;
j:=j+i;
end;
end;
end;
end;
procedure mang_a;
begin
z:=1;
// writeln(max);
for i:=1 to max do
begin
if p[i]=true then
begin
a[z]:=i;
inc(z);
end;
end;
end;
function ghep(x,y:int64):int64;
var y1:int64;
begin
y1:=y;
while y>0 do
begin
y:=y div 10;
x:=x*10;
end;
exit(x+y1);
end;
procedure giai;
begin
d:=0;
// writeln(z);
for i:=1 to z div 2 do
begin
t:=ghep(a[i*2-1],a[i*2]);
// writeln(t);
co:=false;
if t<max then
begin
if p[t]=true then co:=true ;
end
else
if ktnt(t)=true then co:=true;
if co=true then
begin
inc(d);
if d=k then
begin
writeln(t);
exit;
end;
end;
end;
end;
begin
assign(input,'MPRIME.inp');reset(input);
assign(output,'MPRIME.out');rewrite(output);
nhap;
sang;
mang_a;
giai;
//write(d);
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
MPRIME Pascal
Đă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.