Oh, yes. I get it now. Thanks a lot!
Hi there! Your code is awesome. However, I have a confusion. When you calculate the number of periodic strings, you sum the number of periodic strings of its proper divisors. But doesn't it overcount? For example, in calculating the periodic strings for 6, it sums up the periodic strings of 1, 2, and 3. In every case, 111111 and 00000 will be counted.
Can you please tell me where am I wrong?
Okay, I got it to run in O(N), but I did not actually remove the w vector. I used another set to duplicate the values in the w vector. You can see my code here: Online C++ Compiler & Debugging Tool
However, I would like to know how you were approaching the problem by eliminating the w vector. Thank you very much for your answer and support.
You can store the wealths of ancestors in a vector and subtract from the maximum of that vector and store the result in another vector. This would be O(N) I think.
I am approaching the Wealth Disparity via a graph solution. My code is pasing all the testcases except one, which is showing the following error: RE (SIGABRT)(0.540000)
My code is here: Online C++ Compiler & Debugging Tool
Can anybody please tell me what exactly this error means and why am I getting this error?
Can anybody please tell me what's wrong with my code?
My logic is to calculate forward[i], which stores the score of Calvin from k to i. And also calculate backward[i], which stores the score of Calvin from i to 1. And at the end, calculating maximum of forward[i]+backward[i].
My code: Online C++ Compiler & Debugging Tool
I am getting WA at Codechef for this code.