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. hive 命令行传入参数

    azkban实现任务重跑 我们执行sql的方式是将hql文件上传到服务器本地.然后执行shell命令 hive " -f ./test_scheduler.hql 注:hive -e 是执行 ...

  2. commons-text 生成指定长度的随机字符串

    package com.skylink.junge.demo; import java.util.HashSet; import java.util.Set; import org.apache.co ...

  3. 微信公众号UX分析—— 学生作业小结

    1. 不足: 1. 权威性:个人帐号,显得不够正式. 2. 排版问题: + 没有必要的外接端口,界面设计极度缺少排版.哪怕是个人公众号都不至于如此,更何况这是一个学校的教务平台. 3. 反应不及时或无 ...

  4. 项目中使用同一dll的不同版本

    在一个项目中,因为使用了一些插件,这些插件使用了不同版本的log4net,有1.2版本,有2.0版本的.当运行的时候发生冲突. 解决办法:在config中加入如下的配置 <dependentAs ...

  5. Thinking in Java from Chapter 11

    From Thinking in Java 4th Edition 持有对象 // Simple container example (produces compiler warnings.) // ...

  6. accept:Invalid Argument

    错误 #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> int accept(int sockfd, ...

  7. 使用swoole进行消息推送通知,配合vb.net进行客户端开发一样爽[开发篇]

    在以前的项目中,就曾听说过swoole的大名,想用来进行消息推送,但是当时只是有了初步的了解,并不敢大胆的运用到线上产品.所谓 识不足则多虑,威不足则多怒.所以就是怕,只能跟领导说了运用极光的推送功能 ...

  8. python之进程(multiprocess)

    有人说测试学习多进程(或多线程)有啥用?额告诉你很有用,特别是在自己写性能测试工具时就可以用到,而且非常方便 这里只介绍非常简单的多进程模块(multiprocessing.Process) 代码如下 ...

  9. Python内置常量

    引言 Python内置的常量不多,只有6个,分别是True.False.None.NotImplemented.Ellipsis.__debug__. 一. True 1. True是bool类型用来 ...

  10. Hadoop服务库与事件库的使用及其工作流程

    Hadoop服务库与事件库的使用及其工作流程   Hadoop服务库: YARN采用了基于服务的对象管理模型,主要特点有: 被服务化的对象分4个状态:NOTINITED,INITED,STARTED, ...