How can I deal with *huge* integers (more than 10^50 for example, see 10007th problem) ? I've heard of <openssl/bn.h>, but I don't know if it is allowed in ACM.
Otherwise, do you think it is light enough to dynamically store the integers in decimal form in a char*, and to implement addition and multiplication the same way one does with a paper and a pen ?
Well, openssl/bn.h is not part of ANSI C, so it's most likely either forbidden or not accessible at all.
The do-it-yourself method with arrays is the usual way, yes. And if you want to make it faster, use int[] and base 10000 instead of char[] and base 10.
You can also look at the sourcecode of java.math.BigInteger...
You may find StrAdd and StrMul useful.
StrAdd adds two positive integers (<=8000 digits) and returns the result as a string.
StrMul multiplies two positive integers (<=2000 digits) and returns the result as a string.
If there are bugs, let me know.
[c]
int StrToInt(char *p, long *a, int ndigit)
{
int len = strlen(p);
int i, j=0, k = 0;
char t[9];
int q = len/ndigit, r = len%ndigit;