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-07-30 04:30:13 atef
@Ankush very good and gratz for accepted :) |
|||||||||
2015-07-14 07:13:52
i am getting WA for the 5th test case plzz can someone help.. (edit)nevermind got the mistake Last edit: 2015-07-14 07:42:21 |
|||||||||
2015-07-13 10:43:53 hrishabh
be alert when your ans is 1...its give me 2 WA :) Last edit: 2015-07-13 10:44:48 |
|||||||||
2015-07-09 21:38:41 mrx
@atef, I can't understand, i did this with array and same logic without array. Also, I maintained all conditions in both the situations. For negatives and zeroes too. without array : AC with array : WA ? |
|||||||||
2015-07-08 11:13:28 prodigy_coder
@atef can u plzzz check my solution? Donno y I am getting WA. |
|||||||||
2015-06-29 20:26:54
@atef where can be any wrong case? Last edit: 2015-07-01 23:08:14 |
|||||||||
2015-06-28 12:35:45 Sandip Jana
GOT 2 WA DUE TO THAT 's' missing if answer is 1 :(.. Be Careful |
|||||||||
2015-06-27 10:03:08 Ankush
I'm still getting WA, @atef can you check my solution :/ |
|||||||||
2015-06-26 03:18:03 atef
@ping_of_deth try this test case man 12354 25478654 it should output 3 your code output 2 only :( |
|||||||||
2015-06-25 16:36:43 ping_of_death
@atef....plzzz can u look at my submission |