CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » DreamSpark 3 » ARBITRARY PRECISION ARITHMETIC

ARBITRARY PRECISION ARITHMETIC

Problem code: DSPC301

  • All Submissions

All submissions for this problem are available.

ARBITRARY PRECISION ARITHMETIC

Every Programming Language defines some datatypes. Most famous datatypes in the world of programming are the primitive datatypes such as Integer and Char. However, for implementation and memory management issues these sizes of these datatypes are fixed.

Though fixing the size of datatypes is simple, it has its own disadvantages. The two major disadvantages are Overflow and Precision-Compensation.

In many Cryptographic applications and also in various mathematical applications such as calculation of values of irrational numbers such as π, it becomes necessary to override the fixed size of the datatype. This is done by the use of Arbitrary Precision Numbers, whose digits of precision are limited only by the available memory of the host system.

Your task is to write a program that adds two arbitrary precision signed numbers.

Note: The only allowed languages are C and C++

©Vishal Gupta

Input:

First line contains number of test cases, integer n < 20.Each test contains two signed integers on two lines of arbitrary length. Number of digits of the arbitrary precision numbers may extend upto 1000000.

Output:

You need to print the sum of the two arbitrary precision signed numbers.

Sample Input:

4

43789743298749823748374982374

-8349328423487287236483487236482734

4382749374923749238749234982364

-90834789348732648723

-9878947468732648374

48738479234239423840823

-982347983479832748932748923

-5664879843749837248972398472398

Sample Output:

-8349284633743988486659738861500360

4382749374832914449400502333641

48728600286770691192449

-5665862191733317081721331221321


Author: ganesha
Date Added: 27-03-2010
Time Limit: 7 sec
Source Limit: 70000 Bytes
Languages: C, C99 strict, CLOJ, CPP 4.0.0-8, CPP 4.3.2, F#, GO, PERL6, PYTH 3.1.2, TEXT


  • Submit

Comments

  • Login or Register to post a comment.

my program is running well on

dabbcomputers @ 24 Apr 2010 11:45 PM

my program is running well on machine but i am getting runtime error.........i am using only 1.6mb memory i chkd on my submission page and getting 0.00 time................ could anybody tell me why it is happening.... i am using dev c++ on my machine....

i got my error could any body

dabbcomputers @ 24 Apr 2010 11:47 PM

i got my error could any body tell me what is the time limit.....??

@admiin could you specify

dabbcomputers @ 26 Apr 2010 05:47 PM

@admiin

could you specify the tiime limit for this problem...??

@ Organisers First of all ,

f03nix @ 27 Apr 2010 03:18 AM

@ Organisers

First of all , thank you for organising the contest. I really enjoyed solving the problems. One thing i esp. liked about the contest was the level of the questions, which being not that hard enticed you to try your hand at them. However , i have a few suggestions to make.

1. Like some users, i too found that the language in the problems at times was misleading or the problems lacked definiteness .  In my opinion, the problems with clear and well defined goal but difficult to write (in algorithm) are better than the ones where the trick involves interpreting the problem in the right way.

2. Please decide on the test cases before the contest and freeze them to whatever they are ( weak or not but otherwise correct ). Changing them in an ongoing contest would just lead to people getting frusterated ... as it happened here.

3. I really don't think using the number of submissions is a great way to judge a winner in a tie, esp. since you can create a fake account in a jiffy to test your problems on. Instead if possible, include a tie-breaker question like codechef's monthly competition. Judging on time/resources is the same thing ... but a tie-breaker is a neat solution for ties.

Well said, Antarpreet.After

ron @ 27 Apr 2010 11:32 AM

Well said, Antarpreet.

After changing test data of "prime triples", organizers informed us.

But i got frustrated , when i saw my AC submission as TLE in problem "S L LONEY" . Organizers changed test data of this problem also without informing us.

@Surendra Input Files for

MSP_bitmesra @ 27 Apr 2010 05:23 PM

@Surendra

Input Files for Prime Triples were not changed. I just mailed to help people solve that Question.Input/Output files were changed for R D Sharma and was communicated. The problem was rejugded.

@ Vishal: Sir can you give

shadow @ 27 Apr 2010 05:35 PM

@ Vishal:

Sir can you give more details about the event and its forthcoming contests?

@Antarpreet Rules are decided

MSP_bitmesra @ 27 Apr 2010 05:42 PM

@Antarpreet

Rules are decided prior to contest; they were mentioned as Guidelines 3 days before the contest began. You should have communicated then.

However, the good news is that, since not many people are tied at the top positions, people with 10 correct submissions are declared winners for the contest. And those with 9 correct submissions are runner-ups.

 

@ALL However, don't assume

MSP_bitmesra @ 27 Apr 2010 07:51 PM

@ALL

However, don't assume the CodeChef rankings as of now. We are yet to make the Submissions Public by All Contestants. If any one is found sharing codes or using any other mal-practices. They'll be disqualified.

 

@Vishal Please , visit your

ron @ 27 Apr 2010 09:40 PM

@Vishal

Please , visit your mail box.

 

@Vishal .. I didn't know who

f03nix @ 27 Apr 2010 09:49 PM

@Vishal ..

I didn't know who to contact before the contest started and i didn't want to comment while the contest was still on (didn't want to give anyone any ideas). Anyway, neither of my suggestions were for the current contest .. they were just requests from my side for any future contests that you may conduct :)

 

@Surendra

Yeah, i saw the TLE on your solution for S L Loney , weird that it happened. It definitely isn't fair :/

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com