how to handle big number in c++ ?

How to solve bina problem on spoj in python its okay solved easily but in c/c++ how can i do it ?

You can accept both the binary numbers as strings and convert them to decimal form by storing them in ‘long long’(long long can be used to store 64 bit numbers) datatype. You can then check whether they are divisible and print the result accordingly.

You can google for big integer class in c++, but i think the best way is to learn python as its easy and might come handy.

but i always in trouble how to use big interger class in c++ .

I have used too but getting WR .

Use unsigned long long. Just long long only allows you to store positive numbers with up to 63 bits which might overflow. If it still doesn’t work there is another problem. Using some BigInteger class will possibly be too slow.

used too…!! but same result WA

@darkhire21 : Share the code :slight_smile:

Well, then there’s probably another problem. Can’t tell without your solution.

Can anyone please post a link/tutorial of BigInt class for C++ ?

i want also …!!

the type of the result of pow will be determined by its arguments unless the template parameter is specified explicitly, so pow(2,n-i-1) will be an int, yielding a wrong result. You should cast the results to unsigned long long.

Better yet use bitshifting instead of a function 1ULL<<i yields 2^i, but in a faster way (1ULL is 1 with a datatype of unsigned long long)

//