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

Problem from ECPC qualifications day 2

Правка en2, от Chess.Master, 2023-08-10 14:28:12

Hello codeforces. I am trying to upsolve the problems of qualification day2 of ECPC and i need some help on this problem.

Screenshot-from-2023-08-10-13-13-19

The solution that i implemented was a dp solution where dp[i] is the answer for i. so before run any testcase i calculate the dp from 1 to 1e6, and to do this i cal min(dp[i-1]+1, dp[i/j]+j) where j is every divisor of i.

I tried different codes to make this fast and the fasted code that came in my mind was by generate all the prime divisors of i and then calculate the all the divisors of each i from its prime divisors.

But even this code take around more than 3 seconds on my machine. Can anyone please help me with this problem? I want to know if my idea was right and if so will this solution pass in the contest? unfortunately they don't write the time for each test case

Here is my CPP code
Теги ecpc, upsolving, time limit, help, icpc

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Chess.Master 2023-08-10 14:29:31 6
en2 Английский Chess.Master 2023-08-10 14:28:12 20
en1 Английский Chess.Master 2023-08-10 14:26:20 2687 Initial revision (published)