Finally I understood the problem and produces correct output for all test cases.
my solution:-my solution
Accepted solution:- Correct one
logic similar to solution of correct one. Produces output which matches with accepted one.
Still Im getting WA for last test case can any one find corner case which my solution fails.
@l_returns I have coded as per ur algorithm I understood thanks but plz help me to find final case for which its getting wrong.
@vijju123 can u plz see to this because u know this problem
Welcome code_man, I just checked you code… Seems that logic is fine… Good job you finally did that… Logic is definitely correct…
Try changing gets to scanf cuz input might have some “white spaces” which would get you wrong answer…
Do let me know if it worked or not…
thanks finally for reply how much I shoul award u wait let me first try
kya gyata hu toh refresh kari kari ne thako waiting for someones reply
It’s sunday… I took holiday from discuss codechef… though replied to you now…
It worked finally 10th trial thanks bro very happy. But scanf() will scan only till non whitespace character. so if foRmula has whitespace scan() will not consider entire formula but gets() will .So actually gets() should be working.??
ok may be in gets() if encountered whitespace might go into default case:
not matching any above case hence all blunder in calculation.Am I right?
The basic difference between them is…
#scanf() ends taking input upon encountering a whitespace, newline or EOF
#gets() considers a whitespace as a part of the input string and ends the input upon encountering newline or EOF.
link to the discussion on difference between them…
using gets is not safe and preferable…
can u throw light on diff between gets() and fgets(). why some online judge gives me error when I use gets() .