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 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.

hide comments
Jaswanth: 2015-08-21 06:10:27

carry 0 -> No carry operation.
carry 1 -> 1 carry operation.
carry> 1 -> x carry operations.
check this s at the last. the rest is a piece of cake

Baojun Wang: 2015-08-14 03:08:38

foldr..

shally darbari: 2015-08-08 19:49:13

can u plz check my code and tell my mistake id:14853862 why wa??

done...

Last edit: 2015-08-09 20:08:54
shantanu tripathi: 2015-08-07 18:51:11

should be moved to tutorials .... alok too agreed...:P

alok singh: 2015-08-05 20:26:17

two wrong ans.. due to silly mistake.... @atef
@ANIKET
finaly accepted :p

Last edit: 2015-08-05 20:30:57
ANIKET: 2015-08-02 05:27:19

why my code is not accepting @atef
id 14797611
can get some help

Dushyant Singh: 2015-07-30 05:15:15

Does input contain leading zeros?
Please see 14779982. I cannot figure out where i am getting WA.

Last edit: 2015-07-30 05:43:18
atef: 2015-07-30 04:57:44

@mrx in array code this test case is wrong
4 5
0 999999999
0 0
it should be
No carry operation.
No carry operation.

atef: 2015-07-30 04:40:28

@prodigy_coder
9 0
0 0
try this test case your code output no thing :)

atef: 2015-07-30 04:32:01

@akomarov i can't understand your question :)


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