Faulty Odometer

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=4278

Description

You are given a car odometer which displays the miles traveled as an integer. The odometer has a defect, however: it proceeds from the digit 2 to the digit 4 and from the digit 7 to the digit 9, always skipping over the digit 3 and 8. This defect shows up in all positions (the one's, the ten's, the hundred's, etc.). For example, if the odometer displays 15229 and the car travels one mile, odometer reading changes to 15240 (instead of 15230).

Input

Each line of input contains a positive integer in the range 1..999999999 which represents an odometer reading. (Leading zeros will not appear in the input.) The end of input is indicated by a line containing a single 0. You may assume that no odometer reading will contain the digit 3 and 8.

Output

Each line of input will produce exactly one line of output, which will contain: the odometer reading from the input, a colon, one blank space, and the actual number of miles traveled by the car.

Sample Input

15
2005
250
1500
999999
0

Sample Output

15: 12
2005: 1028
250: 160
1500: 768
999999: 262143

HINT

题意

有辆车的里程表坏了,3和8都不能显示,会直接跳过去,给你汽车里程表,输出实际跑了多远

题解:

8进制转10进制

代码

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
const int maxn=;
#define mod 1000000009
#define eps 1e-7
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** int d[]={,,,,,,,};
map<int,int> H;
ll pow(ll x,ll y)
{
if(y==)
return ;
ll ans=;
for(int i=;i<y;i++)
ans*=x;
return ans;
}
int main()
{
ll n;
H[]=,H[]=,H[]=,H[]=,H[]=,H[]=,H[]=,H[]=;
while(cin>>n)
{
if(n==)
break;
printf("%lld: ",n);
ll ans=;
ll t=;
while(n)
{
ans+=(H[n%])*(pow(,t++));
n/=;
}
cout<<ans<<endl;
}
}

HDU 4278 Faulty Odometer 8进制转10进制的更多相关文章

  1. hdu 4278 Faulty Odometer(进制转换)

    十进制转八进制的变形: #include<stdio.h> int main() { int n; while(scanf("%d",&n)!=EOF& ...

  2. hdu 4278 Faulty Odometer

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4278 #include<cstdio> #include<cstring> # ...

  3. SQLSERVER 16进制与10进制转换

    最近工控项目中遇到的16进制与10进制转换,在.NET中比较容易实现,在SQLSERVER中发现没有直接的转换,尤其是出现超出范围的long负数,即无符号64位整数在sqlserver中的存储.网上找 ...

  4. delphi 中字符串与16进制、10进制转换函数

      //字符串转成16进制代码function strToHexStr(str:string):string;varc:char;ss:string;i:integer;beginwhile str& ...

  5. java中16进制转换10进制

    java中16进制转换10进制 public static void main(String[] args) { String str = "04e1"; String myStr ...

  6. php 36进制与10进制转换

    php 36进制与10进制转换 /** * @desc im:十进制数转换成三十六机制数 * @param (int)$num 十进制数 * return 返回:三十六进制数 */ function ...

  7. PHP进制转换[实现2、8、16、36、64进制至10进制相互转换]

    自己写了一个PHP进制转换程序,一个类吧,第一次写这个东东,写这个东东,在处理文本文件时能用得到.   可以实现: 10进制转换2.8.16.36.62进制2.8.16.36.62进制转换10进制 有 ...

  8. 16进制转10进制 HDU-1720

    A+B Coming Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  9. golang中字符串、数值、2进制、8进制、16进制、10进制、日期和字符串之间的转换

    package main import ( "fmt" "reflect" "strconv" "time" ) fun ...

随机推荐

  1. Folding

    题意: 给定一个串,求能化成的最短循环节串(把重复字符串转化成循环节形式) 分析: 不是太好想,如果让求最短长度还好,dp[i][j],表示区间[i,j]化成的最小长度,dp[i][j]=min(dp ...

  2. 《DevOps故障排除:Linux服务器运维最佳实践》读书笔记

    首先,这本书是Linux.CN赠送的,多谢啦~ http://linux.cn/thread-12733-1-1.html http://linux.cn/thread-12754-1-1.html ...

  3. DHCP工作过程详解

    DHCP动态主机配置协议的作用我想作为网管的兄弟们都应该知道了,这里我就不多废话了,今天我要谈的是DHCP的工作过程,了解了工作过程,要排除故障就容易了.   一.DHCP客户机初始化: 1. 寻找D ...

  4. TV端产品设计法则和分析

    对TV端产品设计的分析太特么少了.翻遍网络,大多也是针对UI设计的分析,这篇从产品设计的角度,梳理下现有的TV端产品设计法则,顺道做点分析.(前方多图,高能预警) 目录: 1. TV端产品使用场景 2 ...

  5. Java的平台无关性

    转载自:http://www.cnblogs.com/Y/archive/2011/03/22/JavaVM_Learning_Chapter2_Platform_Independence.html ...

  6. erlang 基础知识

    一 数据类型 1. 整数 Integer Erlang可表示任意大的整数,大整数自动转换成bignums类型,比固定大小的整数类型相对效率较低. Base#Value 表示基数不是10的整数.如:2# ...

  7. Hadoop学习笔记(7) ——高级编程

    Hadoop学习笔记(7) ——高级编程 从前面的学习中,我们了解到了MapReduce整个过程需要经过以下几个步骤: 1.输入(input):将输入数据分成一个个split,并将split进一步拆成 ...

  8. Linux系统github使用

    命令行下使用: 1.检查ssh key cd ~/.ssh 如果提示"No such file or directory",则需要创建一个ssh key. 2.创建ssh key. ...

  9. HDU-3401 Trade 单调队列优化DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3401 DP方程容易想出来,f[i][j]表示第i天拥有j个股票的最优解,则: 1.不买不卖,f[i][ ...

  10. java.lang.IllegalStateException: Cannot call sendError() after the response has been committed

    http://blog.csdn.net/chenghui0317/article/details/9531171 —————————————————————————————————————————— ...