공리, n = 83 (59 초)
-- copy the below text in the file name "thisfile.input"
-- and give something as the command below in the Axiom window:
-- )read C:\Users\thisuser\thisdirectory\thisfile
)cl all
)time on
-- controlla che l'array a e' formato da elementi a.i<=a.(i+1)
tv(a:List PI):Boolean==(for i in 1..#a-1 repeat if a.i> a.(i+1) then return false;true)
-- funzione incremento: incrementa a, con #a=n=b/3,sotto la regola di "reduce(+,a)+#a-1>=reduce(*,a)"
-- e che n<reduce(*,a)<3*n ed reduce(+,a)<3*n
inc3(a:List PI):INT==
i:=1; n:=#a; b:=3*n
repeat
if i>n then return 0
x:=reduce(*,a)
if x>=b then a.i:=1
else
y:=reduce(+,a)
if y>b then a.i=1
else if y+n-1>=x then
x:=x quo a.i
a.i:=a.i+1
x:=x*a.i
if tv(a) then break
else a.i:=1
else a.i:=1
i:=i+1
if x<=n then return inc3(a) -- x<=n non va
x
-- ritorna una lista di liste di 4 divisori di n
-- tali che il loro prodotto e' n
g4(n:PI):List List PI==
a:=divisors(n)
r:List List PI:=[]
for i in 1..#a repeat
for j in i..#a repeat
x:=a.i*a.j
if x*a.j>n then break
for k in j..#a repeat
y:=x*a.k
if y*a.k>n then break
for h in k..#a repeat
z:=y*a.h
if z=n then r:=cons([a.h,a.k,a.j,a.i],r)
if z>=n then break
r
-- ritorna una lista di liste di 3 divisori di n
-- tali che il loro prodotto e' n
g(n:PI):List List PI==
a:=divisors(n)
r:List List PI:=[]
for i in 1..#a repeat
for j in i..#a repeat
x:=a.i*a.j
if x*a.j>n then break
for k in j..#a repeat
y:=x*a.k
if y=n then r:=cons([a.k,a.j,a.i],r)
if y>=n then break
r
-- cerca che [a,b] nn si trovi gia' in r
searchr(r:List List List PI,a:List PI,b:List PI):Boolean==
aa:=sort(a); bb:=sort(b)
for i in 1..#r repeat
x:=sort(r.i.1);y:=sort(r.i.2)
if x=aa and y=bb then return false
if x=bb and y=aa then return false
true
-- input n:PI
-- ritorna r, tale che se [a,b] in r
-- allora #a=#b=n
-- ed reduce(+,a)=reduce(*,b) ed reduce(+,b)=reduce(*,a)
f(n:PI):List List List PI==
n>100000 or n<=1 =>[]
a:List PI:=[]; b:List PI:=[]; r:List List List PI:=[]
for i in 1..n repeat(a:=cons(1,a);b:=cons(1,b))
if n~=72 and n<86 then m:=min(3,n)
else m:=min(4,n)
q:=reduce(*,a)
repeat
w:=reduce(+,a)
if n~=72 and n<86 then x:= g(w)
else x:=g4(w)
if q=w then r:=cons([copy a, copy a],r)
for i in 1..#x repeat
for j in 1..m repeat
b.j:=(x.i).j
-- per costruzione abbiamo che reduce(+,a)= prodotto dei b.i=reduce(*,b)
-- manca solo di controllare che reduce(+,b)=reduce(*,a)=q
if reduce(+,b)=q and searchr(r,a,b) then r:=cons([copy a, copy b],r)
q:=inc3(a)
if q=0 then break
r
결과 :
for i in 2..83 repeat output [i, # f(i)]
[2,2][3,4][4,3][5,5][6,4][7,6][8,5][9,7][10,7][11,8][12,6][13,10][14,7][15,7]
[16,10][17,10][18,9][19,12][20,7][21,13][22,9][23,14][24,7][25,13][26,11]
[27,10][28,11][29,15][30,9][31,16][32,11][33,17][34,9][35,9][36,13][37,19]
[38,11][39,14][40,12][41,17][42,11][43,20][44,12][45,16][46,14][47,14][48,13]
[49,16][50,14][51,17][52,11][53,20][54,15][55,17]
[56,14][57,20][58,17][59,16][60,15][61,28][62,15][63,16][64,17][65,18]
[66,14][67,23][68,20][69,19][70,13][71,18][72,15][73,30][74,15][75,17][76,18]
[77,25][78,16][79,27][80,9][81,23][82,17][83,26]
f 3
[[[1,2,5],[8,1,1]],[[1,3,3],[7,1,1]],[[1,2,3],[1,2,3]],[[2,2,2],[6,1,1]]]
Type: List List List PositiveInteger
Time: 0.07 (IN) + 0.05 (OT) = 0.12 sec
Axiom에서 위의 텍스트를 실행하는 방법은 파일의 모든 텍스트를 파일에 복사하고 이름을 사용하여 파일을 저장합니다. Name.input, Axiom 창에서 ") read absolutepath / Name"을 사용하십시오.
결과 : (# f (i)는 배열 f (i)의 길이, 즉 솔루션 수를 찾습니다)