I was trying the question http://www.spoj.com/problems/JULKA/.
I used vector to solve it i m getting right answer on codeblocks as well as on ideone.But getting segmentation fault on spoj.
Can anyone plz tell me the possible reason for this.
inputA and inputB are identical except for the vector that they populate. Why not create one function that takes the vector as a parameter: long input(vector<int> &vec);
n=(n<<1)+(n<<3)+c-'0';
It would be much clearer to say n = 10*n+c-'0';. Let the compiler decide if the optimization is worth it.
inputA() and inputB() are attempting to return the number, but the number can be as high as 10^100, which will overflow the value of a long int. Since you only care if the result is large, consider using a double, or just always using your vector to determine the answer.
Line 50: what if A<100 but B is 10^50?
Line 84 handles extra digits in A. What if the extra digits are in B, not A?
Line 165: Same problem as line 84.