hdu4278
题目
你有个坏的里程表,下一个数字如果要显示3或者8,它会跳着显示下一位,现在问你实际上的里程是多少。
思路
一开始想到8进制,但是直接搞是不对的,要把每个数字映射一下,或者是把3和8压到后面,这样处理起来才不会有歧义,有意思。
代码
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
int b[
10]= {
0,
1,
2,
0,
3,
4,
5,
6,
0,
7};
int main()
{
ll a;
while(
scanf(
"%I64d",&a)&&a)
{
ll k=
1;
ll ans=
0;
ll d=a;
while(a)
{
ans+=k*b[(a%
10)];
a/=
10;
k*=
8;
}
printf(
"%I64d: %I64d\n",d,ans);
}
return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-1124707.html