Блог пользователя Heisenberg_480

Автор Heisenberg_480, история, 2 недели назад, По-английски

After reducing the problem to x*(x-1)/n*(n-1)=1/2, we can observe the first few values of n and x for which this equation is satisfied using a simple C++ program.We get first few values of n as 1,64,21,120,697 etc if we observe the difference of these numbers they are 3,17,99,577,...etc which is nothing but 2^2-1,4^2+1,10^2-1,24^2+1,... then we see that 2,4,10,24 follow a pattern and term t(i) of this series is t(i-1)*2+t(i-2).We can simply write a dp and keep adding the differences to a variable to keep track of value of n we have reached.Whenever our sum reaches over 1e12,we break the loop.This is the first value of n over 1e12 to satisfy the equation.We then simple substitute n in original equation and solve the quadratic for x.

  • Проголосовать: нравится
  • +12
  • Проголосовать: не нравится

»
2 недели назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

wtf

»
2 недели назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by Heisenberg_480 (previous revision, new revision, compare).