PROFF - Professor Farouk Question

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 students 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:

 1234
+5678
 ----
 6912
  • 4 + 8 = 2 and carry 1
  • carry + 3 + 7 = 1 carry 1
  • carry + 2 + 6 = 9 carry 0
  • carry + 1 + 5 = 6

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

Input

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

Output

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.

Example

Input:
123 456
555 555
123 594
0 0

Output:
No carry operation.
3 carry operations.
1 carry operation.

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

hide comments
2016-02-26 22:43:57 rahul_verma
Too much WA but finally done it
2016-02-25 16:32:48
Please check my code, I really can't find the error... My submission id is 16362479
2016-01-12 16:53:45 cute_girl_1
input format costed 3wa :(

Last edit: 2016-01-12 17:02:23
2016-01-02 17:35:33
@atef Can you check my solution? I have no idea what might be wrong with it, all test cases I can think of are fullfilled

Last edit: 2016-01-02 17:42:25
2016-01-02 13:05:19 shubham
for testcase 4898748546 5465456123
why it gives zero on spojtoolkit?
2015-12-22 22:27:36 Akshit Johry
please check my solution..all possible cases i think are fulfilled
..it was the full stop :'(


Last edit: 2015-12-22 22:35:01
2015-11-23 10:09:16 Dushyant Singh
Strings -_-

Take input like cin>>a>>b not like cin>>a.

EDIT - Can be done without strings too.

Last edit: 2015-11-23 11:21:10
2015-11-22 11:39:24
@easy.......use array.....pass this 1 999999....ans is 6.
2015-09-28 17:06:09
@dushyant output contains leading zeroes....
2015-09-12 16:04:34
have satisfied all conditions of spoj toolkit. spellings are all correct. but getting wrong answer. please help.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.