#129. 判断整数是否接近10的倍数
判断整数是否接近10的倍数
Within 2 of a Multiple of 10
Background
Congcong is currently studying number properties. He wants to know if a given non-negative integer is "close" to a multiple of 10.
Problem Description
Given a non-negative number num, return true if num is within 2 of a multiple of 10. This means that the result of is or .
For example, if a number is a multiple of 10, its distance to a multiple of 10 is . If a number is a multiple of 10 plus or minus , the distance is . If a number is a multiple of 10 plus or minus , the distance is .
Note: (a % b) is the remainder of dividing by , so (7 % 5) is .
Input Format
Input is given from standard input in the following format.
num(a non-negative integer)
Output Format
Output is printed to standard output in the following format.
trueorfalse
Sample
12
true
17
false
19
true
Sample Explanation
- Sample 1:
num = 12. . Since , returntrue. - Sample 2:
num = 17. . Since does not satisfy nor , returnfalse. - Sample 3:
num = 19. . Since , returntrue.
Constraints
Time limit: 1 second, Memory limit: 1024 KiB for each test case.
num is a non-negative integer.