Faulty Odometer

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2102    Accepted Submission(s): 1456

Problem 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
 

Source

八进制转十进制

 //2017-09-29
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; int digit[], tot; int main()
{
int n;
while(cin>>n && n){
int ans = , tmp = n;
tot = ;
while(tmp){
int a = tmp%;
if(a >= )a -= ;
else if(a >= )a -= ;
digit[tot++] = a;
tmp /= ;
}
for(int i = tot-; i >= ; i--){
ans *= ;
ans += digit[i];
}
cout<<n<<": "<<ans<<endl;
} return ;
}

HDU4278的更多相关文章

  1. HDU4278 Faulty Odometerd

    开始以为是容斥原理,想着做一下,应该是可以用容斥解决的,有空再过来写一下.题解是进制转换,开始没想到,不过很好理解. 如在10进制里: 1254=  (1*10^3 + 2*10^2 + 5* 10^ ...

  2. hdu4278 小想法

    题意:       有几个计数器,从1开始计数,计数器有问题,没有3,8这两个数字,只要出现3或者8,那么直接跳过,如 12579 下一个数字就是 12590 ,给你一个数字,问他实际计数了多少. 思 ...

随机推荐

  1. ubuntu16.04安装最新版docker、docker-compose、docker-machine

    安装前说明: 本文将介绍在ubuntu16.04系统下安装和升级docker.docker-compose.docker-machine. docker:有两个版本:docker-ce(社区版)和do ...

  2. iOS逆向工程之Cycript

    1.连接设备 打开一个终端,输入指令: iproxy 重新打开一个新的终端,输入指令: ssh -p root@127.0.0.1 这时候会提示输入密码:默认密码为“alpine”.这样就可以连接到设 ...

  3. MySQL基础--字符函数

    1.UPPER和UCASE返回字符串str,根据当前字符集映射(缺省是ISO-8859-1 Latin1)把所有的字符改变成大写.该函数对多字节是可靠的. 2.LOWER和LCASE返回字符串str, ...

  4. .Wait()与.GetAwaiter()之间有什么区别

    两者都是同步等待操作的结果差异主要在于处理异常.使用Wait,异常堆栈跟踪不会改变并表示异常时的实际堆栈,因此如果您有一段代码在线程池线程上运行,那么您将拥有类似的堆栈 ThreadPoolThrea ...

  5. 什么是CDN及CDN加速原理

    目录 CDN是什么? CDN的相关技术 负载均衡技术 动态内容分发与复制技术 缓存技术 谁需要CDN? CDN的不足 随着互联网的发展,用户在使用网络时对网站的浏览速度和效果愈加重视,但由于网民数量激 ...

  6. Maven 项目中的 pom.xml 文件内容说明

    下面是一个比较全面的 POM 文件的结构,当然常用的并不需要这么多配置,视自己的项目需求而定. <project xmlns="http://maven.apache.org/POM/ ...

  7. harbor镜像仓库-02-https访问配置

    harbor镜像仓库-02-https访问配置 harbordockerhttps harbor搭建部署参考上一章节 harbor镜像仓库-01-搭建部署 Harbor默认使用http,给harbor ...

  8. Python模块——subprocess

    subprocess模块 通过Python去执行一条系统命令或脚本. 三种执行命令的方法 subprocess.run(*popenargs, input=None, timeout=None, ch ...

  9. MathWorks官方消息:神经网络工具箱不能编译

    各位会员大家好,大家关心的问题,我已经大部分得到答案. 10月25号-27号我访问了MathWorks公司在波士顿的总部,大家经常关心的问题,我大部分都得到了答案. 关于神经网络工具箱,我与Matla ...

  10. Maven项目报错:Missing artifact****和ArtifactDescriptorException: Failed to read artifact descriptor for***和Cannot change version of project facet Dynamic web module to 2.5

    一.关于Cannot change version of project facet Dynamic web module to 2.5 具体查看博客:http://blog.csdn.net/ste ...