Hi
I've explained the solution for problem D from today's contest in my YouTube video.
It was a nice math based problem, solved using tries. Code link will be added later in the video description.
I will be adding the video for C tomorrow.
If you want daily updates about my channel,
1. Subscribe to the channel.
2. Follow the facebook page.
Cheers!
I don't think you strictly need tries. Just store occurrences of each prefix. But your solution would consume less memory. Solution without tries: 29900524
Can you explain your approach for the problem C
For problem C, you just need to note that for each vertex the number of possible distinct gcds is small. This is because for each descendant of the root, the possible gcds divide lcm(a_root, a_child_of_root). Now keep that for each vertex, and in dfs, update that accordingly and call the dfs for the children.
Thanks rachitiitr! It was wonderfully explained.
Welcome.