Tuesday, September 30, 2014

ACM 1493. One Step from Happiness / В одном шаге от счастья

  We can just check for the numbers N-1 and N+1 and output the answer. The checking part is easy, you need to take the last three digits and sum up and then the rest 3 digits and sum up and check for equality. There is a little thing which we need to take care about. The number can have a preceding 0. For handling it, you can input it as string and then digit by digit add to number 1 where in the end you will have a 7 digit number where the digits from 1 to 6 can be 0s because the number will have an unusable digit 1.


       FULL SOURCE CODE

No comments:

Post a Comment