HDU 4278 Faulty Odometer 8进制转10进制
Faulty Odometer
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=4278
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
HINT
题意
有辆车的里程表坏了,3和8都不能显示,会直接跳过去,给你汽车里程表,输出实际跑了多远
题解:
8进制转10进制
代码
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
const int maxn=;
#define mod 1000000009
#define eps 1e-7
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** int d[]={,,,,,,,};
map<int,int> H;
ll pow(ll x,ll y)
{
if(y==)
return ;
ll ans=;
for(int i=;i<y;i++)
ans*=x;
return ans;
}
int main()
{
ll n;
H[]=,H[]=,H[]=,H[]=,H[]=,H[]=,H[]=,H[]=;
while(cin>>n)
{
if(n==)
break;
printf("%lld: ",n);
ll ans=;
ll t=;
while(n)
{
ans+=(H[n%])*(pow(,t++));
n/=;
}
cout<<ans<<endl;
}
}
HDU 4278 Faulty Odometer 8进制转10进制的更多相关文章
- hdu 4278 Faulty Odometer(进制转换)
十进制转八进制的变形: #include<stdio.h> int main() { int n; while(scanf("%d",&n)!=EOF& ...
- hdu 4278 Faulty Odometer
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4278 #include<cstdio> #include<cstring> # ...
- SQLSERVER 16进制与10进制转换
最近工控项目中遇到的16进制与10进制转换,在.NET中比较容易实现,在SQLSERVER中发现没有直接的转换,尤其是出现超出范围的long负数,即无符号64位整数在sqlserver中的存储.网上找 ...
- delphi 中字符串与16进制、10进制转换函数
//字符串转成16进制代码function strToHexStr(str:string):string;varc:char;ss:string;i:integer;beginwhile str& ...
- java中16进制转换10进制
java中16进制转换10进制 public static void main(String[] args) { String str = "04e1"; String myStr ...
- php 36进制与10进制转换
php 36进制与10进制转换 /** * @desc im:十进制数转换成三十六机制数 * @param (int)$num 十进制数 * return 返回:三十六进制数 */ function ...
- PHP进制转换[实现2、8、16、36、64进制至10进制相互转换]
自己写了一个PHP进制转换程序,一个类吧,第一次写这个东东,写这个东东,在处理文本文件时能用得到. 可以实现: 10进制转换2.8.16.36.62进制2.8.16.36.62进制转换10进制 有 ...
- 16进制转10进制 HDU-1720
A+B Coming Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- golang中字符串、数值、2进制、8进制、16进制、10进制、日期和字符串之间的转换
package main import ( "fmt" "reflect" "strconv" "time" ) fun ...
随机推荐
- Drupal如何处理系统变量?
Drupal的系统变量都保存在数据库variable表中: 然后,开发人员可以通过下面的API函数操作这些系统变量: function variable_get($name, $default = N ...
- selenium webdriver+windows+python+chrome遇见的问题
win7系统,在python中调用ChromeDriver 一直报错 “ selenium.common.exceptions.WebDriverException: Message: 'Chrome ...
- Android 者开发如何选择测试机列表
Android 系统已经分化成多种不同的定制版本,制造厂商的不同手机使用的硬件千差万别.差异化带来良好的用户体验的同时,也给开发者带来的适配的问题.于是每个开发团队都需要面临选择测试机列表的问题.我基 ...
- Tcl之Intro
Tool command language, a widely used scripting tool that was deveoped for controlling and extending ...
- win7启动出现蓝屏STOP: 0X0000007B
解决方法:开机进BIOS,更改Interface Combination,即硬盘的接口种类,由默认的RAID改成了AHCI,保存,重启,一切正常. 事件过程: 今天开机进入win7,在start wi ...
- sphinx下的max_matches取值对SetLimits的影响
使用PHP在客户端执行 $s -> SetLimits(0, 15, 1200); 传递的第三个参数,是服务器端设定当前查询的结果集大小为1200,但是运行结果,确实$s最终查询得到的结果为空值 ...
- Redis批量导入数据
首先准备数据文件 格式为 SET Key0 Value0 SET Key1 Value1 ... SET KeyN ValueN 利用shell转换数据 #!/bin/bash while read ...
- 浅谈Spark(1) - Overview
Spark是UC Berkeley AMP lab所开源的类Hadoop MapReduce的通用并行框架,Spark,拥有Hadoop MapReduce所具有的优点:但不同于MapReduce的是 ...
- 《学习OpenCV》练习题第五章第二题abc
代码: #include <stdio.h> #include <opencv/highgui.h> #include <opencv/cv.h> #include ...
- android系统的文件夹选择器
aFileChooser: https://github.com/iPaulPro/aFileChooser/issues, 这个是最适合android的文件选择器,看看有无可能改成文件夹选择器. f ...