Frankenstein123's blog

By Frankenstein123, history, 5 years ago, In English

So this can be a little bit off-shore to problem solving in general, but I always wonder what to do the best contestants do before a contest. It would be very helpful if they share the pre-contest rituals which help them to calm down, hold their nerves and focus better during the contest. You can take the "before" to be from anything like a day before (does it matter? :p) to anything like 5 seconds before the round starts.

Full text and comments »

  • Vote: I like it
  • +22
  • Vote: I do not like it

By Frankenstein123, history, 5 years ago, In English

Let's suppose I need to calculate $$$a^{b^{c}}$$$ modulo $$$10^9 + 7$$$, with the constraints $$$1 \leq a, b, c \leq 10^{18}$$$. I can calculate $$$ans = b^c$$$ in $$$\mathcal{O}(log(c))$$$, with modulo $$$10^9 + 6$$$, (probably everyone knows how) and then calculate $$$a^{ans}$$$ with modulo $$$10^9 + 7$$$.

But how does first taking $$$10^9 + 6$$$ and then $$$10^9 + 7$$$ work? Can anyone present a formal proof for this? Also are there any other methods to do this?

Full text and comments »

  • Vote: I like it
  • +25
  • Vote: I do not like it

By Frankenstein123, 6 years ago, In English

So after having searched at a number of places online, I have not yet completely understood how the different methods to fill a particular value at every place in a block of memory in C++. For the sake of clarity, I wish to know how the following methods differ.

1)

int arr[100] = {0};

2)

int arr[100];
int main(){
    fill(arr, arr+100, 0);
}

3)

int arr[100];
int main(){
    memset(arr, 0, sizeof(arr));
}

Please describe the difference in the time complexity and performance of these operations and also what happens when they are used for a higher dimension array, like for declarations of the type int arr[100][100][100];.

Full text and comments »

By Frankenstein123, history, 6 years ago, In English

I have a moderate experience of solving DP questions. I got informed about the hackerrank dp problem set. I found it quite challenging (I wasn't able to solve more than 10 problems all by myself). Can anyone give me remarks on the problem set, like its level of difficulty as compared to div2 problems and also general tips on solving non-standard dp problems and dp on graphs?

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it