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. 图像质量评价方法PSNR+SSIM&&评估指标SROCC,PLCC

    update:2018-04-07 今天发现ssim的计算里面有高斯模糊,为了快速计算,先对每个小块进行计算,然后计算所有块的平均值.可以参考源代码实现,而且代码实现有近似的在里面!matlab中中图 ...

  2. Unity3d让某个物体一直正对着相机

    //将以下代码绑定到相机上 using UnityEngine; using System.Collections;   public class LookatScipt : MonoBehaviou ...

  3. C#.Net平台与OPC服务器通讯

    最近,我们Ndolls工作室承接了山大某个自动化控制项目,主要做了一套工控信息化系统,其中有一个功能模块是将系统管理的一部分数据参数发送至OPC服务器,由OPC服务器接收数据后执行相应工控操作.第一次 ...

  4. 「SDOI2016」储能表(数位dp)

    「SDOI2016」储能表(数位dp) 神仙数位 \(dp\) 系列 可能我做题做得少 \(QAQ\) \(f[i][0/1][0/1][0/1]\) 表示第 \(i\) 位 \(n\) 是否到达上界 ...

  5. [EXP]XAMPP 5.6.8 - SQL Injection / Persistent Cross-Site Scripting

    <!-- # Exploit Title: SQL injection (and previous) # Date: -- # Exploit Author: Rafael Pedrero # ...

  6. 剑指offer【02】- 替换空格(Java)

    题目:替换空格 考点:字符串 题目描述: 请实现一个函数,将一个字符串中的每个空格替换成“%20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. ...

  7. Spring Session - 使用Redis存储HttpSession例子

    目的 使用Redis存储管理HttpSession: 添加pom.xml 该工程基于Spring Boot,同时我们将使用Spring IO Platform来维护依赖版本号: 引入的依赖有sprin ...

  8. 使用Dockerfile制作JDK+tomcat镜像

    1.准备好jdk和tomcatapache-tomcat-8.5.32.tar.gzjdk-8u181-linux-x64.tar.gz 注意:a.jdk和tomcat记得从官网下载,否则制作出来的镜 ...

  9. 【PyTorch深度学习60分钟快速入门 】Part3:神经网络

      神经网络可以通过使用torch.nn包来构建. 既然你已经了解了autograd,而nn依赖于autograd来定义模型并对其求微分.一个nn.Module包含多个网络层,以及一个返回输出的方法f ...

  10. 如何用TexturePacker打包素材

    如何用TexturePacker打包素材 TexturePacker是一个非常好用的图片素材打包工具,它能帮助你减少游戏的图片内存使用. 官方下载地址:http://www.codeandweb.co ...