#168. 最接近10的值

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

最接近10的值

Nearest to 10

Background

Congcong is learning how to compare numbers. He wants to find out which of two given numbers is closer to a specific target value.

Problem Description

Given 2 int values, return whichever value is nearest to the value 10, or return 0 in the event of a tie. Note that Math.abs(n) returns the absolute value of a number.

Input Format

Input is given from standard input in the following format.

Two integers aa and bb.

Output Format

Output is printed to standard output in the following format.

An integer representing the value nearest to 10, or 0 if tied.

Sample

8 13
8
13 8
8
13 7
0

Sample Explanation

Sample 1: The absolute distance of 88 from 1010 is 810=2|8 - 10| = 2. The absolute distance of 1313 from 1010 is 1310=3|13 - 10| = 3. 88 is closer to 1010, so 88 is returned.

Sample 2: The absolute distance of 1313 from 1010 is 1310=3|13 - 10| = 3. The absolute distance of 88 from 1010 is 810=2|8 - 10| = 2. 88 is closer to 1010, so 88 is returned.

Sample 3: The absolute distance of 1313 from 1010 is 1310=3|13 - 10| = 3. The absolute distance of 77 from 1010 is 710=3|7 - 10| = 3. Both are equally distant from 1010, so 00 is returned.

Constraints

Time limit: 11 second, Memory limit: 10241024 KiB for each test case.