CF488A.Giga Tower

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 while 42,  - 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.

吉咖塔(Giga Tower)是网络国(Cyberland)中最高也最深的建筑。它共有 17 777 777 77717\,777\,777\,777 层,编号从 −8 888 888 888-8\,888\,888\,888 到 8 888 888 8888\,888\,888\,888。特别地,在 −1-1 层与 11 层之间存在第 00 层。每天,成千上万的游客来到此处,欣赏壮丽的景色。

在网络国,人们相信数字 “8” 是幸运数字(因此吉咖塔地上部分恰好有 8 888 888 8888\,888\,888\,888 层),而一个整数被称为幸运数,当且仅当其十进制表示中至少包含一个数字 “8”。例如,88、−180-180、808808 均为幸运数,而 4242、−10-10 则不是。在吉咖塔中,若你在楼层号为幸运数的楼层编写代码,好运将永远伴随你(顺便一提,本场比赛编号为 #278,也是幸运数,对吧?)。

游客亨利(Henry)前往该塔寻求好运。他当前位于编号为 aa 的楼层。他希望找到最小的正整数 bb,使得他向上行走 bb 层后,所到达的楼层编号是一个幸运数。

输入格式

The only line of input contains an integer a ( - 109 ≤ a ≤ 109).

输入仅包含一个整数 aa(−109≤a≤109-10^9 \leq a \leq 10^9)。

输出格式

Print the minimum b in a line.

输出最小的 b,占一行。

输入输出样例

  • 输入#1

    179

    输出#1

    1
  • 输入#2

    -1

    输出#2

    9
  • 输入#3

    18

    输出#3

    10

说明/提示

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.

对于第一个样例,他必须到达编号为 180 的楼层。

对于第二个样例,他将到达 8。

注意,bb 应为正数,因此第三个样例的答案是 10,而不是 0。

输入解题思路,AI测评打分。不知道怎么写?

首页