Submit | All submissions | Best solutions | Back to list |
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
|
|||||||||
2015-06-20 11:27:58 atef
@VISHAKHA CHICHRA it should ouput 3 man 5+5=10 and carry 1 5+5+1=11 and carry 1 5+5+1= 11 and carry 1 :) |
|||||||||
2015-06-20 11:25:03 atef
@Mani Soni Gratz for accepted :) |
|||||||||
2015-06-20 11:24:07 atef
@[Mayank Pratap] vary good man (Y) :) go go go to be the best |
|||||||||
2015-06-20 11:22:21 atef
vivek 555 445 0 0 try this it should output 3 your code output 1 only :) |
|||||||||
2015-06-16 12:39:54 vivek
Giving WA! provide some test cases for my answer! |
|||||||||
2015-06-10 11:25:38 [Mayank Pratap]
Learnt new thing about array initialisation .... Each day learning something new .. :) |
|||||||||
2015-06-09 17:23:25 Mayank
Can someone provide some tricky test case. I tried almost everything and getting correct ans on ideone but when I submit , I get wrong ans. |
|||||||||
2015-06-07 14:20:12 VISHAKHA CHICHRA
why the ans for ( 555 555) is 3 i think it should be 2 |
|||||||||
2015-06-07 07:36:27 Mani Soni
help me as i am getting WA please provide some tricky test case or do check my submission |