第一次ACM比赛

在慌忙之中被通知第一次参加ACM比赛,虽然只是校内练习赛,但着实小紧张了一把,所以就卡壳在了第一题上,提交了好多次发现总是不对,刚开始编译错误,到测试数据不过,到最后也都没有写完。回来后思考了一下,算法的确错了,又试了几次,终于写完了。下附第一题

A. Giga Tower
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 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.

#include<stdio.h>
int mabs(int h)
{
    if(h<0) h=-h; return (h); } int main() { int i,m,n,j,a,b,c,t,s=1,h=0,o=0,k=0; scanf("%d",&a); for(i=0;i<16;i++) { a++; t=mabs(a); //printf("%d\n",t); for(s=1,k=0,o=0;k<10;k++) { s=s*10; h=t%s; //printf("%d\n",h); if(h==0.8*s) {o++; break; } t=t-h; //printf("%d\n",t);  } if(o!=0) {printf("%d\n",i+1); break;} //printf("%d\n",o);  } return 0; }

 

转载于:https://www.cnblogs.com/linminxuan/p/4131812.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值