jeudi 7 novembre 2019

Solving linear equations in 9 variables in C++

y1+4*y2 + 9*y3 + 16*y4 +25*y5 + 36*y6 + 49*y7 +64*y8 + 81*y9=k^2, y1+y2+y3+y4+y5+y6+y7+y8+y9=n,

0<=yi<= n ,

k>=1,

n<=10^6

Is these a solution ? If yes then smallest value of y1 +2*y2+3*y3+4*y4+5*y5 + 6*y6 + 7*y7+8*y8 +9*y9 ?

Already tried brute force and dynamic programming approach, could not come to a point where getting this is possible within 2 seconds (time-limit) ?

Aucun commentaire:

Enregistrer un commentaire