Блог пользователя Chess.Master

Автор Chess.Master, история, 15 месяцев назад, По-английски

Hello codeforces. I have this problem from ECPC Qualifications. And i am really interested in solving it. I noteced that it can be solved using Mo's algorithm. But unfortinatly I need help to solve this problem

image

Can anyone please help me?

Полный текст и комментарии »

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

Автор Chess.Master, история, 15 месяцев назад, По-английски

Hello codeforeces, I was trying to upsolve the ECPC Q day 2 and I am stuggle with this problem and need some help please.

image

I am thinking of using mo's algorithm but I can't solve this problem. Can any one help me please?

Полный текст и комментарии »

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

Автор Chess.Master, история, 15 месяцев назад, По-английски

Hello codeforces, I am up-solving ECPC qualifications day 2 and i need some help in problem D.

Screenshot-from-2023-08-11-12-16-06

After trying some tests i found that there is a pattern that repeat. and all the numbers between 0 and B-1 that is divisible by the GCD(A,B). And by the way I can easily calculate the the length of this cycle and also the sum of its number. the length = B/GCD(A,B) and the sum = (length*(length - 1)/2) * A Now we can solve the repeated cycles easily. But my problem is how to calculate the tail of it in O(1) .. i.e. lets say A = 1, B = 7, C = 10 ... we have only one repeated cycle which is from 0 to 6 and after that we will have remaining 3 number from the cycle. so we will need to calculate this what i call tail in O(1). as O(N) will get TLE due to the high test cases numbers.

Can anyone please help me with this problem?

Полный текст и комментарии »

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

Автор Chess.Master, история, 15 месяцев назад, По-английски

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

Полный текст и комментарии »

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

Автор Chess.Master, 15 месяцев назад, По-английски

Hello codeforces. I noticed that most of Experienced Programmers prefer Iterative DP over Recursive one. I Know that some hard problem need space optimizations that can be done in iterative only. But I found that they always use the iterative DP. I see that the recursive DP is much easier. So what is the real purpose of that? Is the iterative solution is easier for them !?

Полный текст и комментарии »

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