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 3 to the digit 5, always skipping over the digit 4. This defect shows up in all positions (the one's, the ten's, the hundred's, etc.). For example, if the odometer displays 15339 and the car travels one mile, odometer reading changes to 15350 (instead of 15340).
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 4.
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
aaarticlea/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAARABIDASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAAAAMFBwT/xAAlEAACAQQCAQMFAAAAAAAAAAABAgMABAURBiESIjFBMjZxdbP/xAAYAQACAwAAAAAAAAAAAAAAAAAAAwEEBf/EABsRAQEAAgMBAAAAAAAAAAAAAAEAAgMEEyFh/9oADAMBAAIRAxEAPwDQeRW+SyVnctBIkiiScOk87qm0ciP0aZWA8dkEDZA2fcGPCWPI+PXkUt3GIcQjkyQxTGdtMrAhUVQO5CraVd/UB1pa7cnHmbaW5hjxEktoZJJGulnjChWYsT4lvLoHvr3B1vommvuQYaSe/jGSxrW9yXEiCWIiTe9eWohvs/LH8n5ocDh9jlnsER+zt+9wDE9G0uKWO4hSaGRJIpFDI6MCrKewQR7ilVfFPs7B/r4P5rStB8ZJW9KUqIlKUoi//9k=" alt="" /> Copy sample input to clipboard 
13
15
2003
2005
239
250
1399
1500
999999
0
Sample Output
13: 12
15: 13
2003: 1461
2005: 1462
239: 197
250: 198
1399: 1052
1500: 1053
999999: 531440
分析:根据题目,在十进制里面去掉了4,那么也就是变成了9进制。然后因为跳过了4,那么大于4的值显然就应该减1
#include <iostream>
#include <cmath> using namespace std; int main(int argc, char const *argv[])
{
int number, numT;
while (cin >> number && number != ) {
numT = number;
int k = ;
int result = ;
while (number) {
int t = number % ;
t = t >= ? t - : t;
result += t * pow(, k++);
number /= ;
}
cout << numT << ": " << result << endl;
}
return ;
}

sicily 1240. Faulty Odometer的更多相关文章

  1. HDU 4278 Faulty Odometer 8进制转10进制

    Faulty Odometer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...

  2. Faulty Odometer(九进制数)

    Faulty Odometer Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9301   Accepted: 5759 D ...

  3. poj 2719 Faulty Odometer

    Description You are given a car odometer which displays the miles traveled as an integer. The odomet ...

  4. hdu 4278 Faulty Odometer

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

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

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

  6. [GodLove]Wine93 Tarining Round #8

    比赛链接: http://vjudge.net/contest/view.action?cid=47644#overview 比赛来源: 2012 ACM/ICPC Asia Regional Tia ...

  7. HDU4278

    Faulty Odometer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  8. C语言程序设计100例之(25):确定进制

    例25    确定进制 问题描述 6*9 = 42 对于十进制来说是错误的,但是对于13进制来说是正确的.即 6(13)* 9(13)= 42(13),因为,在十三进制中,42 = 4 * 13 + ...

  9. sicily 中缀表达式转后缀表达式

    题目描述 将中缀表达式(infix expression)转换为后缀表达式(postfix expression).假设中缀表达式中的操作数均以单个英文字母表示,且其中只包含左括号'(',右括号‘)’ ...

随机推荐

  1. codeforces 1027 E. Inverse coloring (DP)

    E. Inverse Coloring time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. 洛谷P1273 有线电视网 【树上分组背包】

    题目描述 某收费有线电视网计划转播一场重要的足球比赛.他们的转播网和用户终端构成一棵树状结构,这棵树的根结点位于足球比赛的现场,树叶为各个用户终端,其他中转站为该树的内部节点. 从转播站到转播站以及从 ...

  3. P5028 Annihilate

    P5028 Annihilate 50个串,任意两两的最长公共子串 回忆最长公共子串求法 1.hash+二分 2.SAM 3.SA,属于不同的串的hei的max 1.hash+二分 暴力两两枚举再跑的 ...

  4. vue2.0 安装及项目搭建(一)

    基本环境安装 1.安装node:从node.js官网下载并安装node.测试:win+R(打开命令行)-------输入cmd-------敲入node -v.如果出现相应版本号,即安装成功: 2.测 ...

  5. 随机抽样一致性算法(RANSAC)示例及源代码--转载

    转载自王先荣 http://www.cnblogs.com/xrwang/p/SampleOfRansac.html 作者:王先荣 大约在两年前翻译了<随机抽样一致性算法RANSAC>,在 ...

  6. 简化版SMO算法标注

    ''' 随机选择随机数,不等于J ''' def selectJrand(i,m): j=i #we want to select any J not equal to i while (j==i): ...

  7. bzoj 1513 POI2006 Tet-Tetris 3D 二维线段树+标记永久化

    1511: [POI2006]OKR-Periods of Words Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 351  Solved: 220[S ...

  8. 3.UiObejct API 详细介绍

    一.点击与长按 1.组件区域位置关系: Rect 对象代表一个矩形区域:[left,Top][ARight,Bottom](即左上角图标到右下角图标) 2.点击与长按相关API: 返回值 API 说明 ...

  9. update condition 字段报错

    mysql> update tf_user_present set condition="0" where id=1;ERROR 1064 (42000): You have ...

  10. JS获取URL中参数值(QueryString)的4种方法分享

    方法一:正则法 function getQueryString(name) { var reg = new RegExp('(^|&)' + name + '=([^&]*)(& ...