FANDOM


弱平方充填列(1,2,4,5,7,9,10,12,14,16,...)

A=9:dim B[∞],B2[∞],B3[∞],B4[∞,∞],B5[∞]
for A2=0 to 9
 for A3=1 to A
  for A34=1 to A3
   A4=A4+1:B[A4]=A3*A3-2*(A3-A34)
  next
 next
 for A4=A4 to 1 step -1
  A=A*A
  for A6=1 to A4
   if B[A6]=1 then
    A7=0:B2[A6]=1
   else
    for A8=1 to A6
     if B[A8]<B[A6] then A7=A6-A8:B2[A6]=B[A6]-B[A8]
    next
   endif
  next
  if B2[A4]+B2[A4-A7]=2 | B[A4]=1 then
   for A9=1 to A*A7
    B[A4]=B[A4-A7]:A4=A4+1
   next
  else
   if B2[A4]=1 then A10=A4-A7 else A10=A4
   for A11=0 to A10
    if B[A10-A11]<B[A10] & B2[A10-A11]=1 then
     A12=1:A13=1:B3[1]=B[A10-A11]-1:B4[A12,1]=0
     for A14=A10-A11 to A4
      if B[A10]-B[A14]=0 then A12=A12+1:B4[A12,1]=0:A13=1
      B4[A12,1]=B4[A12,1]+(B[A14]-B3[1])*pow(A,A-A13):A13=A13+1
     next
     B5[1]=A12:A16=1:A20=0:A15=B[A10]-B[A10-A11]-1
     for A17=A11 to A10
      if B[A10-A17]<B[A10-A11] & B2[A10-A17]=1 then
       A16=A16+1:A18=1:A19=1:B3[A16]=B[A10-A17]-1:B4[A18,A16]=0
       for A21=A10-A17 to A10-A11-A20-1
        if B[A10-A11-A20]-B[A21]=-1 | B[A10-A11-A20]-B[A21]=0 then 
         A18=A18+1:B4[A18,A16]=0:A19=1
        endif
        B4[A18,A16]=B4[A18,A16]+(B[A21]-B3[A16])*pow(A,A-A19):A19=A19+1
       next
       B5[A16]=A18:A20=A17-A11
       if B4[1,1]=B4[1,A16] then
        B4[A18+1,A16]=0
        for A22=1 to B5[1]
         if B4[A22,1]<B4[A22,A16] then
          A22=B5[1]
         else
          if B4[A22,A16]<B4[A22,1] then A22=B5[1]:A17=A10
         endif
        next
       endif
      endif
     next
     if B2[A4]=2 then
      A4=A4-A11:A23=B[A4]-B[A4-A20]
      for A24=1 to A*A20
       B[A4]=B[A4-A20]+A23:A4=A4+1
      next
     else
      B4[A12,1]=B4[A12,1]-mod(B4[A12,1],pow(A,A-A13+2))
      for A25=B5[A16] to 1 step -1
       if 1<A25 & (B4[A25,A16]<B4[A12,1] | B4[A25,A16]/pow(A,A-1)<A15+2) then 
        B4[A25+1,A16]=B4[A25,A16]
       else
        B4[A25+1,A16]=0-B4[A12,1]:A25=1:B5[A16]=B5[A16]+1
       endif
      next
      A4=A10-A11
      if 2<A16 then B4[A12,1]=0-B4[A12,1]
      for A26=1 to A        
       if A16=2 then A32=2:A34=2 else A32=A16:A34=1
       for A33=A32 to A34 step -1
        B3[A33]=B3[A33]+A15
        for A27=1 to B5[A33]
         if B4[A27,A33]<0 then A28=A26 else A28=1
         if A33=1 & A27=A12 then A35=1 else A35=0
         for A29=1 to A28+A35
          for A30=0 to A
           A31=mod(abs(B4[A27,A33]),pow(A,A-A30))
           if A31=0 then A30=A else B[A4]=int(A31/pow(A,A-A30-1))+B3[A33]:A4=A4+1
          next 
         next
        next
       next
      next
     endif
     A11=A10
    endif
   next
  endif
 next
next
print A

強平方充填列(1,2,4,6,9,12,16,20,25,...)

A=9:dim B[∞],B2[∞],B3[∞],B4[∞,∞],B5[∞]
for A2=0 to 9
 B[1]=1:B[2]=2:A3=2
 for A4=2 to A
  B[A3+1]=B[A3-1]+A4*2-1:B[A3+2]=B[A3]+A4*2:A3=A3+2
 next
 for A3=A3 to 1 step -1
  A=A*A
  for A4=1 to A3
   if B[A4]=1 then
    A5=0:B2[A4]=1
   else
    for A6=1 to A4
     if B[A6]<B[A4] then A5=A4-A6:B2[A4]=B[A4]-B[A6]
    next
   endif
  next
  if B2[A3]+B2[A3-A5]=2 | B[A3]=1 then
   for A7=1 to A*A5
    B[A3]=B[A3-A5]:A3=A3+1
   next
  else
   ifB2[A3]=1 then A8=A3-A5 else A8=A3
   for A9=0 to A8
    if B[A8-A9]<B[A8] & B2[A8-A9]<B2[A8] then
     A10=1:A11=1:B3[1]=B[A8-A9]-1:B4[A10,1]=0
     for A12=A8-A9 to A3
      if B[A8]-B[A12]=0 then A10=A10+1:B4[A10,1]=0:A11=1
      B4[A10,1]=B4[A10,1]+(B[A12]-B3[1])*pow(A,A-A11):A11=A11+1
     next
     B5[1]=A10:A13=1:A14=0:A15=B[A8]-B[A8-A9]-B2[A8-A9]
     for A16=A9 to A8
      if B[A8-A16]<B[A8-A9] & B2[A8-A16]<B2[A8] then
       A13=A13+1:A17=1:A18=1:B3[A13]=B[A8-A16]-1:B4[A17,A13]=0
       for A19=A8-A16 to A8-A9-A14-1
        if 0-B2[A8]<B[A8-A9-A14]-B[A19] & B[A8-A9-A14]-B[A19]<1 then
         A17=A17+1:B4[A17,A13]=0:A18=1
        endif
        B4[A17,A13]=B4[A17,A13]+(B[A19]-B3[A13])*pow(A,A-A18):A18=A18+1
       next
       B5[A13]=A17:A14=A16-A9
       if B4[1,1]=B4[1,A13] then
        B4[A17+1,A13]=0
        for A20=1 to B5[1]
         if B4[A20,1]<B4[A20,A13] then
          A20=B5[1]
         else
          if B4[A20,A16]<B4[A20,1] then A20=B5[1]:A21=A16:A16=A8
         endif
        next
       endif
      endif
     next
     if 2<B2[A3] & A5=1 then
      for A22=A21 to A8
       if B[A8-A22]<B[A8-A21] & B2[A8-A22]<B2[A8-A21] then
        A23=A22-1:A24=B3[1]-B[A8-A22]
        A25=A21-1:A3=A3-2:A26=(B3[1]-B2[A8-A21])-B[A8-A22]+1
        for A27=1 to A
         for A28=1 to A23
          A3=A3+1:B[A3]=B[A3-A23]+A24
         next
         for A29=1 to A25
          A3=A3+1:B[A3]=B[A3-A25]+A26
         next
         A23=A23+A25:A24=A24+A26
        next
        A3=A3+1:A22=A8
       endif
      next
     elseif 1<B2[A3]
      A3=A3-A9:A27=B[A3]-B[A3-A14]
      for A28=1 to A*A14
       B[A3]=B[A3-A14]+A27:A3=A3+1
      next
     else
      B4[A10,1]=B4[A10,1]-mod(B4[A10,1],pow(A,A-A11+2))
      for A29=B5[A13] to 1 step -1
       if 1<A29 & (B4[A29,A13]<B4[A10,1] | B4[A29,A3]/pow(A,A-1)<A15+B2[A8]) then
        B4[A29+1,A13]=B[A29,A13]
       else
        B4[A29+1,A13]=0-B4[A10,1]:A29=1:B5[A13]=B5[A13]+1
       endif 
      next
      A3=A3-A9
      if 2<A13 then B4[A10,1]=0-B4[A10,1]
      for A30=1 to A
       if A13=2 then A31=2:A32=2 else A31=A13:A32=1
       for A33=A31 to A32 step -1
        B3[A33]=B3[A33]+A15
        for A34=1 to B5[A33]
         if B4[A34,A33]<0 then A35=A30 else A35=1
         if A33=1 & A34=A10 then A36=1 else A36=0
         for A37=1 to A35+A36
          for A38=0 to A
           A39=mod(abs(B4[A34,A33]),pow(A,A-A38))
           if A39=0 then A38=A else B[A3]=int(A39/pow(A,A-A38-1))+B3[A33]
          next
         next 
        next
       next 
      next
     endif
     A9=A8
    endif
   next
  endif
 next
next
print A

広告ブロッカーが検出されました。


広告収入で運営されている無料サイトWikiaでは、このたび広告ブロッカーをご利用の方向けの変更が加わりました。

広告ブロッカーが改変されている場合、Wikiaにアクセスしていただくことができなくなっています。カスタム広告ブロッカーを解除してご利用ください。

FANDOMでも見てみる

おまかせWiki