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

174/1464

Solve/Submission

Ranking

# User Language Timing
01 jonyroy Cpp14 0.00s
02 MAHRahat Cpp14 0.00s
03 maxhasan Cpp14 0.00s
04 afzalul Cpp14 0.00s
05 Reayz Cpp 0.00s
06 shahed_shd Cpp14 0.00s
07 Indro_BU Cpp14 0.00s
08 Ss_1230 Cpp 0.00s
09 sirpoka Cpp14 0.00s
10 jayed_al_hasan Cpp14 0.00s
11 ashikur_rahman Cpp14 0.00s
12 Ehsanul_Fahad Cpp 0.00s
13 Morass Cpp14 0.00s
14 rithu Cpp14 0.01s
15 shameemreza Cpp 0.01s
16 RRizkiR Cpp 0.01s
17 sazzad33r C 0.01s
18 epmahfuz Cpp14 0.01s
19 hmtanbir Cpp14 0.01s
20 sb_rithu Cpp14 0.01s
21 porag Cpp14 0.01s
22 parthapratimbanik Cpp14 0.01s
23 khmahbub20 Cpp 0.01s
24 rashedul_riad Cpp14 0.01s
25 sjsakib Cpp14 0.01s
26 ammasum Cpp14 0.01s
27 ProMAGFAT Cpp14 0.01s
28 sadia2427 Cpp14 0.01s
29 Dragon_162 Cpp14 0.01s
30 Rajan_sust Cpp14 0.01s
31 Rakib05 Cpp 0.01s
32 masumkhan Cpp 0.01s
33 SKL12 Cpp14 0.01s
34 Tamim028 Cpp 0.01s
35 feodorv Cpp14 0.01s
36 anik_JU Cpp14 0.01s
37 kpretomazi Cpp 0.01s
38 Chayti_Saha98 Cpp14 0.01s
39 imAnik Cpp14 0.01s
40 Rahat_BU Cpp14 0.01s
41 FariD Cpp14 0.01s
42 onucsecu Cpp14 0.01s
43 mohibur Cpp14 0.01s
44 rayhan50001 Cpp14 0.01s
45 arafatduha Cpp14 0.01s
46 Emdadul_Hoque Cpp14 0.01s
47 Knight_King Cpp14 0.01s
48 Shammo Cpp14 0.01s
49 saiful130104 Cpp14 0.01s
50 joy25896 Cpp14 0.01s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support