Little Chef and Numbers

Note :There may be trailing spaces on each line of input. …it is given in ques
i have written code for this problem…and it is giving wrong answer on codechef…
i m unable to understand the what is going wrong…
i think it may be due to trialing spaces…
does scanf takes trailing spaces as input or skips trailing spaces…
if it takes then how to prevent it for doing so…

See my question - http://discuss.codechef.com/questions/39438/little-chef-and-numbers-runtime-exception

For sure there are no trailing spaces in first line (the line for T).

Scanf ignores trailing spaces between the numbers.

Wrong answers in simple problems are mainly due to following :

  1. accessing undeclared memory e.g. accessing A[25] when it is declared as A[25].
  2. Data range is larger than that of the data-type of variable storing the value.
    // It is common to declare variables of type [b]unsigned long long int[\b] here!
  3. Some corner cases which are problem specific.

Debug, debug, debug … your code till you get an AC.
(and think harder to find the special cases of problems!)

2 Likes

@surajtripathi: I deleted your last comment…

You cannot share your logic, answer, input, code, hint, algorithm, etc.

read more here - guidelines

//