from itertools import product
i = open('input.txt', 'r')
o = open('output.txt', 'w+')
l = int(i.
alpha = "245"
d = []
for s in product(alpha, repeat=l):
d.append([" ".join(
for q in d[1: ]:
s = " ".join(q)
if int(s.count('2')) > 2:
continue
o.write(" ".join(q) + '\n')
i.close()
o.close()
код к : «перевод кода с питона на паскаль»
var
n,c,i,ost,b,t,d: integer;
a,k: string;
begin
readln(n);
c: =1;
for i: =1 to n do
c: =c*3;
c: =c-1;
for i: =1 to c do
k: ='';
b: =i;
t: =0;
while b> 0 do
ost: =b mod 3;
if ost=0 then inc(t);
d: =(-sqr(ost)+5*ost+4)div 2;
str(d,a);
k: =a+k;
b: =b div 3;
end;
while length(k)do
k: ='2'+k;
inc(t);
if t< =2 then writeln(k);
end.
from itertools import product
i = open('input.txt', 'r')
o = open('output.txt', 'w+')
l = int(i.
alpha = "245"
d = []
for s in product(alpha, repeat=l):
d.append([" ".join(
for q in d[1: ]:
s = " ".join(q)
if int(s.count('2')) > 2:
continue
o.write(" ".join(q) + '\n')
i.close()
o.close()
код к : «перевод кода с питона на паскаль»
var
n,c,i,ost,b,t,d: integer;
a,k: string;
begin
readln(n);
c: =1;
for i: =1 to n do
c: =c*3;
c: =c-1;
for i: =1 to c do
begin
k: ='';
b: =i;
t: =0;
while b> 0 do
begin
ost: =b mod 3;
if ost=0 then inc(t);
d: =(-sqr(ost)+5*ost+4)div 2;
str(d,a);
k: =a+k;
b: =b div 3;
end;
while length(k)do
begin
k: ='2'+k;
inc(t);
end;
if t< =2 then writeln(k);
end;
end.
5591(20), 5623(16), 5639(23), 5641(16), 5647(22), - 4
5651(17), 5653(19), 5657(23), 5659(25), 5669(26), - 1
5683(22), 5689(28), 5693(23), 5701(13), 5711(14), - 3
5717(20), 5737(22), 5741(17), 5743(19), 5749(25), - 2
5779(28), 5783(23), 5791(22), 5801(14), 5807(20), - 4
5813(17), 5821(16), 5827(22), 5839(25), 5843(20), - 3
5849(26), 5851(19), 5857(25), 5861(20), 5867(26), - 3
5869(28), 5879(29), 5881(22), 5897(29), 5903(17), - 2
5923(19), 5927(23), 5939(26), 5953(22), 5981(23), - 2
5987(29), 6007(13), 6011(09), 6029(17), 6037(16), - 1
6043(13), 6047(17), 6053(14), 6067(19), 6073(16), - 2
6079(22), 6089(23), 6091(16), 6101(08), 6113(11), - 3
6121(10), 6131(11), 6133(13), 6143(14), 6151(13), - 2
6163(17), 6173(17), 6197(23), 6199(25), 6203(11), - 0
6211(10), 6217(16), 6221(11), 6229(19), 6247(19), - 2
6257(20), 6263(17), 6269(23), 6271(16), 6277(22), - 3
6287(23), 6299(26), 6301(10), 6311(11), 6317(17), - 2
6323(14), 6329(20), 6337(19), 6343(16), 6353(17), - 3
6359(23), 6361(16), 6367(22), 6373(19), 6379(25), - 2
6389(26), 6397(25), 6421(13), 6427(19), 6449(23), - 1
6451(16), 6469(25), 6473(20), 6481(19), 6491(20), - 3
6521(14), 6529(22), 6547(22), 6551(17), 6553(19), - 3
6563(20), 6569(26), 6571(19), 6577(25), 6581(20), - 3
6599(29), 6607(19), 6619(22), 6637(22), 6653(20). - 3
Всего 120 простых чисел, из них 57 имеют четную сумму цифр.