# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
Name |
---|
E was quite good tbh.
can someone please explain me the solution of problem E in detail ...i am too dumb to understand this
I struggled quite a lot with problem E. Hope this explanation helps you.
Let’s first look at the constraints of the problem, here the value of (n = 100) and the value of (a <= 10^4) and (1 <= b <= 10000). We have to find the value of the expression (n * a — b). So, what can be the max value of this expression? If n = 100 and a = 10^4 and assuming b = 1 (because the minimum value of b can be 1) we get that the max value of the expression becomes (n * a — b = 10^2 * 10^4 — 1) = 999999. From this deduction what can we say? There will be 6 digits maximum in the final solution we want to find. If there are more than 6 digits we can simply ignore those answers because we found out the max value to be of 6 digits. So, the problem has been reduced to a minimized version and can be solved with brute force on the value of 'a' only.
If we run a loop for a from 1 to 10^4, and inside that loop we firstly find digits(n) * 'a', which is basically the number of digits in the number (n * a) for each value of 'a'. Now as we know this value (digits(n) * a) must not be greater than 6. Because as we discussed earlier those values will not contribute to our answer. So, we run a loop of digits(d) from 1 to 6 and can find from that b = (digits(n) * a — d). In case you didn't get this point what was the original equation supposed to be? (digits(n) * a — b = d).
From this, you got the value of both a and b. Now you can calculate the original value of n * a — b and the value digits(n) * a — b and compare if both of them are equal. If both of them are equal then these (a, b) pairs will contribute to your answer. And as we are running a loop for the value of a only from 1 to 10^4 and n = 100(max) and for the digits 1 to 6.
The total time complexity reduces to 100 * 10000 * 7 ~ 10^7(roughly). Which is fast enough to pass the test cases.
thanks... understood it very well
amazing explanation I was not able to understand the editorial but your explanation was to the point and simple to understand.
Your explanations are very beginner friendly ,keep going brother <3
I'm glad to hear that.
Shayan sir, a small suggestion from my side, if you are doing official video editorial then why don't you just give testing to the round and prepare your videos in advance?? (I know there will be no live discussion happens if this works, but I think you will get more time analyse the harder problems and come up with a good problem discussion) just a personal opinion.
You are right. I will test this idea.
Thank you for explaining question F very well