Description

Giga Tower is the tallest and deepest building in Cyberland. There are 17 777 777 777 floors, numbered from  - 8 888 888 888 to8 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 alllucky 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.

Input

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

Output

Print the minimum b in a line.

Sample Input

Input
179

Output
1

Input
-1

Output
9

Input
18

Output
10

Hint

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.

代码:

 1 #include<stdio.h>
 2 int function(int n)
 3 {
 4     int t,m=0;
 5     while(n>0)
 6     {
 7         t=n%10;
 8         if(t==8)
 9         {
10             m=1;
11             break;
12         }
13         n=n/10;
14
15     }
16     return m;
17 }
18        int main()
19 {
20     int n,g,i;
21     while(scanf("%d",&n)!=EOF)
22     {
23         for(i=1,n=n+1; i<20; i++)
24         {
25             if(n>=0)g=function(n);
26             else g=function(-n);
27             if(g)break;
28             n++;
29         }
30         printf("%d\n",i);
31     }
32     return 0;
33 }

转载于:https://www.cnblogs.com/dongq/p/4131202.html

A - Giga Tower相关推荐

  1. A. Giga Tower

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  2. Codeforces 488A Giga Tower

    Giga Tower 题目链接: http://codeforces.com/problemset/problem/488/A 解题思路: Codeforces官方题解: The answer b i ...

  3. Codeforces 488A Giga Tower(水)

    题目链接:Codeforces 488A Giga Tower #include <cstdio> #include <cstring> #include <cstdli ...

  4. 题解系列009 | 洛谷题解 CF488A 【Giga Tower】

    原题传送门:Giga Tower 一.题意 题目(传送门)给一个绝对值不超过十位的整数,想计算至多加几后会在和数中出现数字 888. 二.分析 看到这道题,我们最容易想到的当然是暴力枚举,但是首先需要 ...

  5. codeforces 488A. Giga Tower 解题报告

    题目链接:http://codeforces.com/problemset/problem/488/A 题目意思:给出一个数a,范围是[-10^9, 10^9],问它最少需要加的一个正整数 b 是多少 ...

  6. Codeforces Round #278 (Div. 2)

    A. Giga Tower 模拟即可,略过 B. Candy Boxes 四个整数x1..x4,满足x1<=x2<=x3<=x4,假如sum x1..x4/4 == x2+x3 /2 ...

  7. dwarf tower

    [问题描述] Vasya在玩一个叫做"Dwarf Tower"的游戏,这个游戏中有n个不同的物品, 它们的编号为1到n.现在Vasya想得到编号为1的物品. 获得一个物品有两种方式 ...

  8. Codeforces Gym 100269 Dwarf Tower (最短路)

    题目连接: http://codeforces.com/gym/100269/attachments Description Little Vasya is playing a new game na ...

  9. 如何攻克异地协作难题?看 Tower 的 72 个月远程工作实践

    12 月 9 日,TGO 鲲鹏会武汉分会成功组织了第一次小组活动.在此次小组活动中,Tower 联合创始人 & TGO 鲲鹏会武汉分会会员徐峥带来了<Tower 团队 72 个月远程协作 ...

最新文章

  1. 网络工程师转售前的条件
  2. 推荐10个小众简约,但是实用的软件和网站
  3. mysql查询日期内的所有日期代码
  4. 阿里云成为首个通过《面向公有云模式的政务云服务》测评的厂商
  5. 一个查看 SAP UI5 控件所有公有方法的小技巧
  6. java中什么是守护线程_什么是Java的守护线程?
  7. 背景选择器selector替换按钮默认背景
  8. Spring MVC的处理流程详解
  9. 2017-2018网络攻防第四周作业
  10. mysql-connector-java 5.1.13,Java连MySQL,mysql-connector-java-5.1.13-bin.jar究竟要怎
  11. 差分进化算法DE优化BPNN
  12. 英语作文 计算机新技术对生活的影响,科技的影响高中英语作文3篇
  13. [Python]Spyder常用设置方便使用-持续更新
  14. 世界主要港口中英文对照表
  15. 常见七种逻辑门真值表
  16. 二路归并排序原理及JAVA实现
  17. java返回pdf文件流给前端_如何实现springmvc将返回的给前端的pdf文件放在浏览器里预览?...
  18. Centos7安装并配置MySQL5.7
  19. 文梳理世界11国家和地区ICO政策:监管趋严,展现定义证券倾向
  20. 简述机车计算机控制系统的组成,简述机车微机控制系统主要功能? - 问答库

热门文章

  1. 如何使keystone更有效率
  2. [转]Yii Framework: 从 model 中生成 select option
  3. [C#]结构体和字节数组的相互转化
  4. printf 打印 文件名 函数名 行号
  5. 多线程之 interrupt,interrupted,isInterrupted 方法区别
  6. [Python] L1-023. 输出GPLT-PAT团体程序设计天梯赛GPLT
  7. 1050. 螺旋矩阵(25)-PAT乙级真题
  8. (哈哈)漫画告诉你什么是屎一样的代码(屎里蕴含着代码的秘密)
  9. 如何在原生微信小程序中实现数据双向绑定
  10. Java多线程之Runable与Thread