I feel i am stuck…means from the start i am only able to solve 4-5 problems in long(4 this time)

what should i do @vijju123

The jump from 4th to 5th and 5th to 6th is quite much. Previous long’s 6th was really tough, while fifth was quite easy (and on geeksforgeeks).

At least this time, assuming you did Class 12th Maths, the fifth question should be in your hands if you spend some time and know some basic tricks of number theory. Think on what the question actually wants, like, as in, “What do I need to calculate to get the answer?”

There are a few approaches for solving questions.

- Direct answer calculation- Usually for O(1)
- Lets say, we did some thinking and observed some dependencies of the answer on some factors. Like, lets say, Ans=A(x)*B(y). Now our job is to find A(x)*B(x). Lets say, we see that B(y) can be trivially calculated. Now we just need A(x). Repeat the step until its not possible anymore. The “peeled” question of finding A(x) should be simpler provided you do it correctly.
- Finding a big dependency helps as well. Lets say, we observe that "Answer can be trivially calculated provided I get an expression to find F(x) in O(A(t)) time. Lets take an example. A guy sees that to find F(t), he needs F(t-1). i.e, F(t)=K*F(t-1). If we can know F(t-1), then we can get the answer. Change variables both sides as t\implies t-1, now to find F(t-1) we need F(t-2). At the end of this ladder, there will be some base case like F(0),F(1),F(2) etc, which can be trivially calculated. Now we can use simple recursion to find F(t). Next comes optimising, where you might have to search or think of tricks like storing previous values, or something else to find it efficiently. This is the toughest part- but at least we did some progress in the problem right?

1 Like