Can someone explain why the condition in Question C the condition is Root(n) in the tutorials? link to problem: https://mirror.codeforces.com/contest/1426/problem/C
# | User | Rating |
---|---|---|
1 | jiangly | 3977 |
2 | tourist | 3815 |
3 | jqdai0815 | 3682 |
4 | ksun48 | 3614 |
5 | orzdevinwang | 3526 |
6 | ecnerwala | 3514 |
7 | Benq | 3483 |
8 | hos.lyric | 3381 |
9 | gamegame | 3374 |
10 | heuristica | 3358 |
# | User | Contrib. |
---|---|---|
1 | cry | 170 |
2 | -is-this-fft- | 162 |
3 | Um_nik | 161 |
4 | atcoder_official | 159 |
5 | djm03178 | 157 |
6 | Dominater069 | 156 |
7 | adamant | 154 |
8 | luogu_official | 152 |
8 | awoo | 152 |
10 | TheScrasse | 147 |
Can someone explain why the condition in Question C the condition is Root(n) in the tutorials? link to problem: https://mirror.codeforces.com/contest/1426/problem/C
Name |
---|
After x operations of type-1 and y operations of type-2, the sum of resulting array will be (x + 1)*(y + 1).
We have to minimise (x + y), such that (x + 1)*(y + 1) >= n. Note that for any number N, two numbers A, B such that A*B = N, you will get minimum (A + B) for such A which is closest to square root of N. If you try to plot a graph, it will be a parabola with minima at square root of n, hence you can either use ternary search or check few values near sqrt(n).