#P4689. Divisibility by Eight
Divisibility by Eight
Divisibility by Eight
题面翻译
题目描述
给你一个位数不超过 100 的非负整数 N(不含前导 0)。你的任务是判断这个数字能否通过去掉其中的一些位上的数(当然不能去掉全部),使其成为一个能被 8 整除的正整数(不含前导 0)。特别注意:你不能重新排列数字的顺序。
输入输出格式
输入
一行,表示正整数 N。保证 N 不超过 100 位。
输出
如果不能达成条件,则输出 “NO”(不含引号)。
如果可以,输出 “YES”,并在第二行输出最终能被 8 整除的那个结果。如果有多解,则输出任意解。
题目贡献人:SSH_oj uid=41262
题目描述
You are given a non-negative integer , its decimal representation consists of at most digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.
If a solution exists, you should print it.
输入格式
The single line of the input contains a non-negative integer . The representation of number doesn't contain any leading zeroes and its length doesn't exceed digits.
输出格式
Print "NO" (without quotes), if there is no such way to remove some digits from number .
Otherwise, print "YES" in the first line and the resulting number after removing digits from number in the second line. The printed number must be divisible by .
If there are multiple possible answers, you may print any of them.
样例 #1
样例输入 #1
3454
样例输出 #1
YES
344
样例 #2
样例输入 #2
10
样例输出 #2
YES
0
样例 #3
样例输入 #3
111111
样例输出 #3
NO