Codeforces Round #278 (Div. 2)-A. Giga Tower_html/css_WEB-ITnose
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Giga Tower is the tallest and deepest building in Cyberland. There are 17?777?777?777 floors, numbered from ?-?8?888?888?888 to 8?888?888?888. In particular, there is floor 0 between floor ?-?1 and floor 1. Every day, thousands of tourists come to this place to enjoy the wonderful view.
In Cyberland, it is believed that the number "8" is a lucky number (that's why Giga Tower has 8?888?888?888 floors above the ground), and, an integer is lucky, if and only if its decimal notation contains at least one digit "8". For example, 8,??-?180,?808 are all lucky while42,??-?10 are not. In the Giga Tower, if you write code at a floor with lucky floor number, good luck will always be with you (Well, this round is #278, also lucky, huh?).
Tourist Henry goes to the tower to seek good luck. Now he is at the floor numbered a. He wants to find the minimum positive integer b, such that, if he walks b floors higher, he will arrive at a floor with a lucky number.
Input
The only line of input contains an integer a (?-?109?≤?a?≤?109).
Output
Print the minimum b in a line.
Sample test(s)
input
179
output
input
-1
output
input
18
output
10
Note
For the first sample, he has to arrive at the floor numbered 180.
For the second sample, he will arrive at 8.
Note that b should be positive, so the answer for the third sample is 10, not 0.
题目大意:给一个数n,加上k之后,使得n中包含数字8. 求这样的最小的正整数k.
解题思路:其实本题的最大的k也就是16(n == -8时),直接在这里面暴力查找,然后每个都判断是否含有8即可。不过要注意,在判断的时候,如果是直接取模的话,则要注意 -8 % 10 == -8.
AC代码:
#include#include #include #include #include #include #include #include
上一篇: 关于CI表单验证类
推荐阅读
-
Codeforces Round #655 (Div. 2) A. Omkar and Completion
-
Codeforces Round #659 (Div. 2) A. Common Prefixes(字符串,思维)
-
Educational Codeforces Round 93 (Rated for Div. 2) A. Bad Triangle
-
Codeforces Round #664 (Div. 2) A. Boboniu Likes to Color Balls
-
Codeforces Round #156 (Div. 2)-A. Greg's Workout_html/css_WEB-ITnose
-
Codeforces Round #107 (Div. 2)-A. Soft Drinking_html/css_WEB-ITnose
-
Codeforces Round #191 (Div. 2)-A. Flipping Game_html/css_WEB-ITnose
-
Codeforces Round #279 (Div. 2)_html/css_WEB-ITnose
-
Codeforces Round #278 (Div. 2)B?? Candy Boxes_html/css_WEB-ITnose
-
Codeforces Round #277.5 (Div. 2) 解题报告_html/css_WEB-ITnose