DCP-1: Big Sum Back to All Problems

Medium Math > Big Integer Arithmetic

Anik, a student of mathematics is doing a research for his PhD degree. He thinks if he can complete his work, it will help mankind a lot. But the problem is as part of his research he needs to check sum of two numbers in a special way. The numbers themselves will be big enough plus the sum needs to be done in a reversed way. For example, if two numbers were 24 and 13, we have to first reverse these numbers to make them 42 and 31 and then we have to do the addition so the sum will be 42 + 31 = 73. Afterwards he needs to output the result as reversed again, so the output will be 37 actually. One advantage he has is that the input numbers will never have leading zero. But the resulted sum if has any leading zeroes need to be removed. For example, if we have two numbers such as 911 and 199, then the reversed numbers will be 119 and 991 and the sum will be 119 + 991 = 1110. So, if we reverse, the output should be 0111, but actually we have to consider 111 as output because we should remove all leading zeroes in final output. As it is hard for Anik to check numbers that can be as long as 100 digits, so he wants to hire a freelancer who can write a small program to help him. He will provide a large input file with these number pairs and expects an output file that finds out the reversed sum. He wants the code as well so that he can run it on other data sets in future. Let’s see whether you can do it or not. Input: ------ Input will consist of many number pairs, each on a separate line and the numbers are separated by a comma. The numbers can be as big as 100 digits long. The numbers will be integer and fractional numbers and negative numbers will not be in input. Input will be terminated by end of file. Output: ------- The output will be the reversed sums each on an individual line of its own. For each input pair, there should be one reversed sum. Sample Input ------------ 199,911 119,991 24,13 Sample Output ------------- 111 111 37

Problem Setter:

MD. Jalal Uddin

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 3.00
Go 3.00
Java 3.00
JavaScript 3.00
Objective-C 3.00
Perl 3.00
PHP 3.00
Python 3.00
Python3 3.00
Ruby 3.00
VB.Net 3.00

Problem Stats




# User Language Timing
01 shahed_shd Cpp14 0.00s
02 maxhasan Cpp14 0.00s
03 jayed_al_hasan Cpp14 0.00s
04 Indro_BU Cpp14 0.00s
05 MAHRahat Cpp14 0.00s
06 ashikur_rahman Cpp14 0.00s
07 afzalul Cpp14 0.00s
08 jonyroy Cpp14 0.00s
09 Reayz Cpp 0.00s
10 Ehsanul_Fahad Cpp 0.00s
11 Morass Cpp14 0.00s
12 sirpoka Cpp14 0.00s
13 ss1230 Cpp 0.00s
14 MRoy Cpp 0.00s
15 wayne6172 C 0.00s
16 Roll_no_152 Cpp 0.00s
17 milon019 C 0.00s
18 deloar1 Cpp 0.00s
19 marayhan C 0.00s
20 fadilcse5bu Cpp 0.00s
21 SugiuraAyano C 0.00s
22 1704107_Imran Cpp 0.01s
23 abdullahaahnaf1 Cpp 0.01s
24 tarikul_4152 Cpp 0.01s
25 Partha11 Cpp 0.01s
26 riadspartanbd C 0.01s
27 shifa33 Cpp 0.01s
28 selepsy Cpp 0.01s
29 shahadat191 Cpp14 0.01s
30 nafischonchol Cpp 0.01s
31 arabin Cpp 0.01s
32 Neon10 Cpp14 0.01s
33 islam2366 C 0.01s
34 Mormo_1703119 Cpp 0.01s
35 Turin Cpp 0.01s
36 purple Cpp 0.01s
37 Nuwaisir Cpp 0.01s
38 71_75 Cpp 0.01s
39 Yeasin10A Cpp 0.01s
40 susmoys Cpp14 0.01s
41 Tahmid Cpp 0.01s
42 nasib_mbstu Cpp 0.01s
43 Sarwar05 Cpp 0.01s
44 armanferdous Cpp 0.01s
45 ahoteshanul Cpp 0.01s
46 mirrafa Cpp 0.01s
47 triangle Cpp 0.01s
48 Shahriar_88 Cpp14 0.01s
49 Jisancse Cpp14 0.01s
50 t0whid Cpp 0.01s

Your feedback is our precious!

Or call +88 02 9853138 for support