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. 使用pyinstaller打包python小程序(没有使用第三方模块)

    准备: 1,xxx.py程序文件 2,自定义的图标文件:xxx.ico 图标文件应该包含常见的多分辨率格式,以便适应在不同场合显示,不能是单一图片. 你可以用专用的软件处理生成图标,不过少量的图标生产 ...

  2. Django Model 基础

    程序涉及到数据库相关操作时,一般都会这样: 创建数据库,设计表结构和字段 使用 pymysql 来连接数据库,并编写数据访问层代码 业务逻辑层去调用数据访问层执行数据库操作 import pymysq ...

  3. 761. Special Binary String

    Special binary strings are binary strings with the following two properties: The number of 0's is eq ...

  4. spring框架学习笔记6:JDBC模板

    JDBC模板:Spring中对数据库的操作. 这一部分对熟悉DBUtils的QueryRunner的开发者来说,非常简单 这是以前我简单写的dbutils的知识: http://www.cnblogs ...

  5. Java实现大数相加、相乘(不使用BigInteger)

    大数相加: package algorithm; //使用BigInteger类验证 import java.math.BigInteger; public class BigAdd { public ...

  6. [Swift]键盘遮挡控件

    键盘遮挡控件: super.viewDidLoad(){ // Do any additional setup after loading the view, typically from a nib ...

  7. Swift5 语言指南(十八) 可选链接

    可选链接是一个查询和调用当前可选的可选项的属性,方法和下标的过程nil.如果optional包含值,则属性,方法或下标调用成功; 如果是可选的nil,则返回属性,方法或下标调用nil.多个查询可以链接 ...

  8. javascript Navigator对象属性和方法

    Navigator对象 Navigator 对象包含的属性描述了正在使用的浏览器.可以使用这些属性进行平台专用的配置.虽然这个对象的名称显而易见 的是 Netscape 的 Navigator 的浏览 ...

  9. Django2.1发布,Django2.1新特性

    Django 2.1 现已正式发布,官方表示随着 2.1 的发布,对 2.0 系列的主流支持服务将结束,进入安全修复服务周期,直至2019年4月. 2.1新特性:https://docs.django ...

  10. Python模块——logging模块

    logging模块简介 logging模块定义的函数和类为应用程序和库的开发实现了一个灵活的事件日志系统.logging模块是Python的一个标准库模块, 由标准库模块提供日志记录API的关键好处是 ...