You are not logged in. Please login at www.codechef.com to post your questions!

×

Operation on Huge numbers in C++

In C++ / C we can't work with very large numbers like 10^100 ,But in some cases we need to work with such large numbers specially for solving some problems.... I searched net and from my own idea I think I can do this by storing all digits in an array and use laws of number theory to do many operations like addition,multiplication and output as string...... But are there other effective ways to do this faster like any library or STL in C++ or C to work with such huge numbers because in live competitions it's really needed to code faster and this way takes lots of memory. Or,Is there any algorithms or technique to do any operation s on large numbers quicker and good way.... Please if you know any links or sites mention. I ll appreciate any help. Thanks :-)

asked 23 Aug '13, 23:31

nabil1997's gravatar image

3★nabil1997
11111716
accept rate: 0%


if u see the top submissions in c/c++ of the problem...http://www.codechef.com/problems/FCTRL2 ...then u'll find that no such stl(if it exists)is being used...just arrays and laws of number theory...if u want to code fast with large numbers( >10 ^ 19) then u can use a diff lang like python(int can store large vals arnd 200!) or maybe java(BigInteger)...hope this helps...:)

link

answered 23 Aug '13, 23:43

kunal361's gravatar image

4★kunal361
6.0k133272
accept rate: 21%

edited 23 Aug '13, 23:46

Thanks,Actually though I know Java and Python I don't use them for solving problems (I am in C++ for more than other ones).... But one thing was bothering me -> how to work with modulus for large numbers Like I have a 100 digit number and another 30 digit number ..I need to find out first number % 2nd number in C++ I aint sure how to do that.. And I saw the FCTRL2 tutorial before Thanks by the way :-)

(24 Aug '13, 10:47) nabil19973★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,901
×1,650
×87

question asked: 23 Aug '13, 23:31

question was seen: 4,844 times

last updated: 24 Aug '13, 10:47