I can't figure it out why my solution got WA. I have read the Tutorial. And my idea is a little different, but I think it's a valid solution. My idea goes like that:
sum = sigma a[i]. do : a[i] = sum — a[i];
and we put all this numbers(a[i]) into a priority_queue. everytime pop out all the smallest one.(maybe more than 1) and count the number(cnt) of smallest one. and if cnt is multiple of x^b(b can't be larger any more) we push a number (smallest number + b) into the priority_queue. and do that again. if cnt is not a multiple of x, then we get the ans we want. (actually ans = min(cnt, sum))
Anyone can tell me why my solution is not correct. Thanks a lot.
I fixed yours solution. Try to understand why it was wrong 5095663
Well,thank you sincerely. And I think I know why it's wrong. The part of cnt that can't be divided by k still useful and cause a effect to the other numbers. I just left it behind. Thank you again.