Little Red Riding Hood and Candy Factory
The problem basically asks to check if the integer is even or odd. As integer is very large you can check if last digit is even or odd to decide the ans. If the integer is even than the ans is YES else ans is NO
Little Red Riding Hood and Convolutions
Convolution(L) = L1*L2*L3*L4 + L2*L3*L4*L5 + ........
Since only allowed values for L[i] is 1 or -1, we can say that the number of terms (Li*Lj*Lk*Ll) which evaluates to -1 are equal to number of terms which evaluates to 1. So, if we negate the given list the number of terms which evaluates to -1 or 1 doesn't change and we get another list L' whose Convolution(L') = 0
An Unfair Fair Game
Graph Sum
if m is odd than no. of ways are zero. if m is even then we have to make n/2 using 1 and 2.
which comes to be sigma(0 to n1) (nk1) C (k) which is actually fibonacci number Fib(n).
taking last 5 digits is mod operation with 1e5. Fib(n) repeats after 150000 when we take mod
with 1e5.
now add the number to every vertex in path from v to vertex 1 (root).
use HLD to perform the queries.
it will take log^2(N) per query.
total complexity = N*log^2(N)