Я обычно отдыхаю как-то так:
Код:
default(parisizemax,10^9)
n=10
m=2
a=1
b=1
c=1
l=vector(2^n,i,0)
for(i=2,2^n,l[i]=l[i\2]+1)
p=vector(2^n,i,0)
for(i=1,2^n-1,p[i+1]=i-2^l[i])
p1=vector(2^n,i,0)
for(i=1,2^n,p1[i]=p[p[i]+1])
p2=vector(2^n,i,0)
for(i=1,2^n,p2[i]=p1[p[p[i]+1]+1])
p3=vector(2^n,i,0)
for(i=1,2^n,p3[i]=p2[p[p[i]+1]+1])
p4=vector(2^n,i,0)
for(i=1,2^n,p4[i]=p3[p[p[i]+1]+1])
h=vector(2^n,i,hammingweight(i))
z0=vector(2^n,i,l[i]+1-hammingweight(i))
s0=vector(2^n,i,0)
s0[1]=1
for(i=1,2^n-1,s0[i+1]=(i%2)*s0[i\2+1])
q=vector(2^n,i,0)
for(i=1,2^n,q[i]=if(i%2==1,1,2*q[i\2]))
s=vector(2^n,i,0)
for(i=1,2^n,s[i]=if(i%2==1,0,s[i\2]+1))
q1=vector(2^n,i,0)
q1[1]=1
for(i=2,2^n,q1[i]=if(i%2==1,q1[i\2],q1[i\2]+s0[i]))
g=vector(2^n,i,0)
g[1]=1
g[2]=1
for(i=2,2^n-1,g[i+1]=if(i%2==1,c*g[i\2+1-q[i\2]],a*g[i\2+1]+0*g[i\2+1-q[i\2]]+b*g[i+1-q[i\2]]))
g11=vector(2^n,i,0)
g11[1]=1
for(i=1,2^n-1,g11[i+1]=g11[i]+g[i+1])
\\g2=vector(2^n,i,factor(gcd(g[i],(a+b)^10)))
\\x=[0, 0, 1, 0, 2, 0, 1, 1, 3, 0, 1, 2, 2, 2, 1, 1, 4, 0, 1, 3, 2, 3, 2, 1, 3, 3, 2, 2, 1, 2, 1, 1, 5, 0, 1, 4, 2, 4, 3, 1, 3, 4, 3, 2, 2, 2, 1, 2, 4, 4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 1, 1, 1, 1, 1, 6, 0, 1, 5, 2, 5, 4, 1, 3, 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2^i]/g1[2^(i-1)]))
\\for(i=0,n\2-1,print(factor(g[(5^i-1)/4+1])))
\\for(i=1,n\2-1,print(g[(4^i-1)/3+1]/(g[(4^(i-1)-1)/3+1])))
C(p, q, n) = if(n<2,1,sum(k=0,n-1,p^k*q^(n-k-1)*sum(j=0,k,q^j*binomial(n+j-2,j)*(n-j-1)/(n-1))))
\\for(i=0,n\2-1,print(C(a, b, i)))
\\T(p, q, n) = if(n<2,1,sum(k=0,n-1,p^k*binomial(n+k-1,k)*(n-k)/(n)))
\\for(i=0,n\2-1,print(T(a, b, i)))
R(p, q, n) = if(n<2,1,b^(n-1)+a*sum(k=0,n-2,b^k))
\\for(i=1,n\2-1,print(R(a, b, i)))
z1(n)=binomial(n+1,2)
z2(n)=binomial(n+2,2)
z(n)=x*z1(n)+y*z2(n)
S(n, k) = if(n==0,1,if(k==-1,0,S(n, k-1) + z(k)*S(n-1, k+1)))
\\for(i=0,n\2,print(S(i,0)))
v=vector(2^n,i,0)
v[1]=0
v[2]=1
for(i=2,2^n-1,v[i+1]=if(l[i]-l[i-1]==1,v[i]+2*4^(l[i]-1) + 3*2^(l[i]-1) - 1,v[i]+(2^(s[i]+2)-3)*2^l[i\(2*q[i])]))
t1(n)=if(n==0,0,if(n%2==1,1-t1(n\2),t1(n\2)))
s1(n)=p[n+1]
l0(n)=if(n<2,0,l0(n\2)+1)
g0(n)=if(n<8,if(n==2,1,0)+2*if(n==4,1,0)+if(n==6,1,0)+if(n==7,1,0),if(p[n+1]<2^(l0(n)-1),g0(2^(l0(n)-1)+p[n+1])-t1(p[n+1])+1,if(p[n+1]<3*2^(l0(n)-2),g0(2^(l0(n)-2)+p[n+1])+1,if(p[n+1]<7*2^(l0(n)-3),g0(2^(l0(n)-3)+p[n+1])+t1(p[n+1]-3*2^(l0(n)-2)),1))))
h1(n,k)=if(k==0,n,if(k==1,s1(s1(n)),h1(h1(n,1),k-1)))
g1(n,k)=if(k==0,g0(n),g1(h1(n,k),0))
a1(n)=(1/g[n+1])*c^g5(n)*prod(k=0,g3(n),(b^(k+1)+a*sum(j=0,k,b^j))^g1(n,k))
g2(n)=sum(k=0,7,if(g1(n,k)==0,0,1))
g3(n)=if(n<4,if(n==2,1,0),if(p[n+1]<2^(l0(n)-1),g3(2^(l0(n)-1)+p[n+1]),g3(p[n+1])+t1(p[n+1]-2^(l0(n)-1))))
g4(n)=if(n==0,0,g4(s1(n))+t1(n))
g5(n)=g4(s1(n))
\\for(i=0,2^n-1,print(g2(i)))
for(i=1,n,print(sum(k=2^(i-1),2^i-1,if(g3(k)==m,c^g5(k)*prod(j=0,m-1,(b^(j+1)+a*sum(s=0,j,b^s))^g1(k,j)),0))/6))
\\print(sum(k=0,2^n-1,a1(k)))
\\for(i=0,n,print(g11[2^i]))
\\for(i=0,n-1,print(if(i==0,1,sum(k=2^(i-1),2^i-1,g[k+1]))))
e(n)=polcoeff(1/(1-x) + sum(k=2,n\2+1,prod(j=2,k,b^(j-1)+a*sum(r=0,j-2,b^r))*x^(2*(k-1))*(1-(b^(k-1)+a*sum(s=0,k-2,b^s)-1)*x)/((1-x)*prod(i=2,k,(1-(b^(i-1)+a*sum(t=0,i-2,b^t))*x)^2))) + x*O(x^n), n)
\\print(sum(i=0,n-1,if(i==0,1,sum(k=2^(i-1),2^i-1,g[k+1]))/e(i)))
\\for(i=0,2^n-1,print(factor(g[i+1])))