PROFF - Professor Farouk Question

no tags 

Professor farouk asked his students to create a variable of type integer and let it equal to 2147483647 then asked them to add 1 for this variable they found that the answer like that -2147483648 while it should be 2147483648. One of students said that we can use long and other said we can use Big Integer in java, but for sure professor farouk know all this things but he wanted to ask what will you do if there's no data type can have your result ?
one of sudents gave the best answer he said we can add multi-digit numbers from right-to-left one digit at a time and print the result. for sure by using this way he will find a carry for example



4+8=2 and carry 1

carry+3+7=carry 1

carry+2+6=9 carry 0


Your job is to create a program that count the number of carry operations.


Each line of input contains two unsigned integers less than 10 digits. The last line of input contains ‘0 0’.


For each line of input except the last you should compute and print the number of carry operations that would result from adding the two numbers, in the format shown below.



123 456
555 555
123 594
123 456 555 555 123 594
0 0
No carry operation. 3 carry operations. 1 carry operation.

hide comments
pranjulpal18: 2018-12-30 13:52:42

What was your logic @abhishak69 ?

abhishak69: 2018-12-11 19:17:21

plzz check my submission why is it showing wrong answer

prakash1108: 2018-01-15 15:55:43

Use of array costed me 9 WA.
Do without taking array.

zeeshan12: 2018-01-14 18:24:02

do check for carry=1
costed me 4 wa

Last edit: 2018-01-14 18:49:13
prasad_235: 2018-01-13 19:40:54

Thank you very much @venkat016

venkat016: 2018-01-08 21:44:16

Thanks to the comment for @prasad_235

swatantragupta: 2016-12-26 19:00:44

one of the input can be 0 but not both.cost me 2 WA

atul_agarwal: 2016-08-22 08:14:18

Please note:
for 0 carry : "No carry operation."
for 1 carry: "1 carry operation."
for n carry(n>1):"n carry operations."

that extra 's' in n carry and no 's' in n=1 carry cost me 3 W.A

mkfeuhrer: 2016-06-20 23:33:09

my 150th!!! first code C++ dont know what was wrong !! second wrote in C with similar AC :-)

ragwave: 2016-05-14 19:28:35

do watch, for carry=1
print "1 carry operation."
for carry=0
print "No carry operation."

Added by:atef
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU JS-MONKEY