I actually managed to finish this code but when i submit the answer i get a “Wrong Answer” error. Since the code worked properly for smaller values, i am assuming the error was caused because i didn’t use the correct data types (i used long long btw).
QUESTION:
Can someone tell me the maximum value of output ?? Based on that i will have to edit my code. 'Cause if the output is in range of “long long”, then my code might be faulty for higher values. But if its above “long long” then i’ll try a little different approach (int array).
I hadn’t solved this question before so to better understand it I gave it a shot in Python got AC. From that point since I know I was generating the correct answers I modified my code a little bit to loop over all possible values of n (1<=n<=16384) and kept a variable to keep track of the maximum output value.
So to answer your question I found that the maximum output value for any valid case in this range is: 16513
Obviously this tells you that your problem lies in incorrect logic and is not related to a data type issue.
Edit: If anyone wants to give this problem a shot the link is here
I will leave it to your correctly modify your code but to give you an idea of where to start see the cases below:
Your responses to n = 1 through n = 5
Case #1
first meets river 1 at 1
Case #2
first meets river 1 at 2
Case #3
first meets river 3 at 3
Case #4
first meets river 1 at 4
Case #5
first meets river 1 at 620
Correct responses to n = 1 through n = 5
Case #1
first meets river 1 at 1
2
Case #2
first meets river 3 at 23
3
Case #3
first meets river 3 at 3
4
Case #4
first meets river 3 at 23
5
Case #5
first meets river 1 at 11
Oh god … how stupid of me … I read the question wrong… i thought river1 meant {1,2,4,8,16, 23, 28…}. Likewise for river2 and river3 … Now i can do the code …
thanks a lot felic92
SuRF666
Also notice that there is a space between the word “Case” and the actual number “#N”. I feel that neglecting this could also yield WA.