• + 2 comments

    I did it using a simple loop and I don't even know what DP is. Could you please show me what a solution using DP looks like?

    function main() {
        let [a, b, n] = input.split(' ').map(Number);
        a = new BigNumber(a);
        b = new BigNumber(b);
        for (let i = 3; i <= n; i++) {
            var c = next(a, b);
            a = b, b = c;
        }
        process.stdout.write(c.toFixed());
    }
    
    • + 1 comment

      DP comes from Dynamic Programming, is an algorithm paradigm or a technique to solve complex problems breaking them into small ones. Just like you I still do not have any idea about what it is or how to implemented. If you find any DP course for dummies, please let me know, the ones I've found are a little bit difficult to follow.

      • + 0 comments

        https://www.youtube.com/watch?v=P8Xa2BitN3I Check this video out, it might be helpful if you want to understand the basics of Dynamic programming.

    • + 0 comments

      Your solution is a DP solution.

      You are calculating tn by solving the problem from t1 to tn, and recording the results in order to calculate the one you need.

      That's the whole idea of dynamic programming: to solve a complex instance of a problem using the solution to smaller instances.

      This problem is so simple that you can't really appreciate the technique. If you want an example of a more "serious" DP algorithm, you might look to a classic like the Wagner–Fischer algorithm to compute the distance between strings. It's simple enough but not trivial.