Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя rachitiitr

Автор rachitiitr, история, 7 лет назад, По-английски

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!

  • Проголосовать: нравится
  • +51
  • Проголосовать: не нравится

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится +4 Проголосовать: не нравится

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

  • »
    »
    7 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Can you explain your approach for the problem C

    • »
      »
      »
      7 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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.

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Thanks rachitiitr! It was wonderfully explained.