#129. 判断整数是否接近10的倍数

    ID: 129 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatLogic-1gesp1条件结构数学基础

判断整数是否接近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 num(mod10)num \pmod{10} is 0,1,2,8,0, 1, 2, 8, or 99.

For example, if a number is a multiple of 10, its distance to a multiple of 10 is 00. If a number is a multiple of 10 plus or minus 11, the distance is 11. If a number is a multiple of 10 plus or minus 22, the distance is 22.

Note: (a % b) is the remainder of dividing aa by bb, so (7 % 5) is 22.

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.

true or false

Sample

12
true
17
false
19
true

Sample Explanation

  • Sample 1: num = 12. 12(mod10)=212 \pmod{10} = 2. Since 222 \le 2, return true.
  • Sample 2: num = 17. 17(mod10)=717 \pmod{10} = 7. Since 77 does not satisfy 727 \le 2 nor 787 \ge 8, return false.
  • Sample 3: num = 19. 19(mod10)=919 \pmod{10} = 9. Since 989 \ge 8, return true.

Constraints

Time limit: 1 second, Memory limit: 1024 KiB for each test case. num is a non-negative integer.