Educational 106 problem D time limit and hacks

Правка en4, от thematdev, 2021-03-19 19:40:39

Hi, Codeforces! I have 13 successful hacks of problem D on last round, and also my solution are TLed(probably on one of my tests :)), and i am going to show you, how does it work.

So we have two part of solution.

Solution and complexity

Now we will try to adjust numbers $$$c, d, x$$$ to hack $$$O(t\sqrt{x} \log x + N \log \log N)$$$ solution. Because we are counting distinct prime factors of numbers like $$$\frac{\frac{x}{d_x} + d}{c}$$$, we will use $$$c = 1$$$. And we are factorizing $$$x$$$. So the first idea is to find $$$x$$$ with biggest divisors number, and that $$$x$$$ is $$$8648640$$$. And then we will try to maximize

$$$\sum\limits_{d_x \mid x} s(x/d_x + d)$$$

where $$$s(n)$$$ -- sum of powers of primes in factorization of $$$n$$$(exactly that much operations we do).

And we have first powerful hack. 10000 tests with $$$c=1, d=x=8648640$$$. List of successful hacks using this method below

But some solutions hadn't hacked by this test. And there are more reasons of it. Sometimes people precalculate lowest divisors powered to its power, and by Second Merten's Theorem it is $$$O(\log \log x)$$$ average, and also our $$$d$$$ doesn't work. But the main reason is memory and cache, so we can use randomized generator with more numbers with huge amount of divisors. But how can we use randomized generator on codeforces? It is simple, we just need to set seed in mt19937 and try to adjust it.

Some examples

Generator code
Теги educational round, #number theory, hacks

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
ru2 Русский thematdev 2021-03-19 20:42:03 47 (опубликовано)
ru1 Русский thematdev 2021-03-19 20:40:52 3063 Первая редакция перевода на Русский (сохранено в черновиках)
en9 Английский thematdev 2021-03-19 20:11:43 0 (published)
en8 Английский thematdev 2021-03-19 20:08:17 203
en7 Английский thematdev 2021-03-19 20:02:34 10
en6 Английский thematdev 2021-03-19 19:57:46 1566
en5 Английский thematdev 2021-03-19 19:43:25 52 Reverted to en3
en4 Английский thematdev 2021-03-19 19:40:39 52
en3 Английский thematdev 2021-03-19 19:36:55 2072
en2 Английский thematdev 2021-03-19 19:29:02 664 Tiny change: '} + d}{c}$\n\n\n\n\n' -> '} + d}{c}$, we will use $c = 1$.\n\n\n\n\n'
en1 Английский thematdev 2021-03-19 19:18:15 1065 Initial revision (saved to drafts)