A plus B... again
Given two integers A and B (of no more than 100000 digits each), find their exact sum.
All Submissions
Best Solutions
Point Value: 15
Time Limit: 3.00s
Memory Limit: 16M
Added: Oct 24, 2008
Languages Allowed:
C++03, PAS, C, ASM, C#, C++11
Comments (Search)
Make sure it's done correctly though
Why is the judge accepting a wrong answer (or is the version of pascal that i am using just messed up)? Also, is this basically the same problem i had before?
I do notice that for several cases you printed '0' instead of a minus sign.
This indicates a general protection fault, probably caused by going out of bounds in memory.
Any cryptic clues?? :P
Why are you using char arrays? Just use strings.
And I am even on the right track??
If you use strings, just use s.length(), where s is a string.
Take a look at my solution. I tried to fix the problem, it still isn't working. :(
say I have the following:
string str;
the length of this string is str.length().
so i can do this:
for (i=0;i<str.length();i++)
cout<<str[i];
which would print the characters of the string.
int vector_size = v.size();
and that returns the number of elements in the vector.
however, vectors are a bit more advanced to use, so as Hanson suggested, become more proficient in C++.
It was suggested twice that you use strings, and I've looked at your submissions and I still see char arrays.
Can someone help me?
Firstly, you mention that one case of 10000 and -1. But does your program work at home on those other cases, such as 10 and 56? If not, fix those first.
But in general, if your program behaves differently at home than on the judge, it means you're going out of bounds. So look over your code carefully - every time you access an array (like x[a]), make sure 1<=a<=(size of x).
Yes, your program is outputting wrong answers.
No, initialization probably won't make a big difference, but you should ALWAYS do it.
As I said, you're probably going out of bounds.
I imagine extended only fits about 19 or so..
It's either faster that 0.1 seconds, or slower than 1.5 seconds...