https://www.codechef.com/problems/GUESSRT The problem was asked on febuary 2019 long challenge.I was able to solve the problem partially using two loops but i got TLE for last two test cases. Can someone share the right approach.Thanks Basically  two approach are possible  1.Chef removes the boxes after every move (if it is not last move ). 2.or greedy approach. I am new to Competitive programming.Also i tried this problem for long time. asked 14 Feb, 16:28

answered 15 Feb, 16:29
1
if you don't understand anything feel free to ask
(15 Feb, 16:31)
Thanks @rajput1999
(15 Feb, 22:15)

Hi @jbhv12 ! I modified your solution and submitted. It got an AC. See here. Because whenever you subtract something then you may get negative value so taking modulo will also result in negative answer. So always do 3) I replaced your line
4) and put %mod on almost every step.
answered 14 Feb, 21:15
correction :
(15 Feb, 22:25)

If CHEF has more than 1 move then he will first remove boxes then he will choose one box. This leads to a GP
$\frac{1}{n} + (1 \frac{1}{n})*\frac{1}{n}+(1 \frac{1}{n})^2*\frac{1}{n}+....$ answered 14 Feb, 18:04
@vichitr I figured out exact same logic. Here's my code getting WA: https://www.codechef.com/viewsolution/22948884 I've been pulling my hair. help me?
(14 Feb, 19:53)
@vichitr Thanks for answer , it was really helpful .How do i prove that removing the boxes after each move is best option. obviously its feels that it should be but how do i prove it.Thanks
(15 Feb, 14:00)

@rajput1999 could you please explain from scratch (atleast name the recommended topics) answered 15 Feb, 22:29
i am a newbie please help me
(15 Feb, 22:31)
It is just a simple maths problem which uses the knowledge of Geometric Progression. Also you need knowledge to find modular multiplicative inverse.
(16 Feb, 03:23)
Thanks man @vichitr ! i appreciate your support ... this is a very nice explanation it's a simple GP i was so confused
(16 Feb, 16:03)

i am a newbie please help me answered 15 Feb, 22:31
check out my already given 2 answers. Logic is explained and you then need to find GP sum as described in my answer.
(16 Feb, 03:26)
Thanks man @vichitr ! i appreciate your support ... this is a very nice explanation it's a simple GP i was so confused
(16 Feb, 16:04)
