poj 2719 Faulty Odometer
Description
Input
Output
Sample Input
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
Source
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define MAX 0
#define inf 0x3f3f3f3f
using namespace std;
int n;
int main() {
while(~scanf("%d",&n) && n) {
int r = ,w = n,mi = ;
while(w) {
int d = w % ;
if(d > )d --;
r += d * mi;
w /= ;
mi *= ;
}
printf("%d: %d\n",n,r);
}
return ;
}
python代码:
while (True):
a = int(input())
if a == 0:
break
wa = a
ra = 0
mi = 1
while a != 0 :
d = a % 10
if d > 3 :
d -= 1
ra += d * mi
a = int(a / 10)
mi *= 9
print("%d: %d"%(wa,ra))
poj 2719 Faulty Odometer的更多相关文章
- HDU 4278 Faulty Odometer 8进制转10进制
Faulty Odometer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- Faulty Odometer(九进制数)
Faulty Odometer Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9301 Accepted: 5759 D ...
- sicily 1240. Faulty Odometer
Description You are given a car odometer which displays the miles traveled as an integer. The odomet ...
- hdu 4278 Faulty Odometer
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4278 #include<cstdio> #include<cstring> # ...
- POJ 2719
#include<iostream> #include<stdio.h> using namespace std; ]; int _pow(int m,int n); int ...
- hdu 4278 Faulty Odometer(进制转换)
十进制转八进制的变形: #include<stdio.h> int main() { int n; while(scanf("%d",&n)!=EOF& ...
- C语言程序设计100例之(25):确定进制
例25 确定进制 问题描述 6*9 = 42 对于十进制来说是错误的,但是对于13进制来说是正确的.即 6(13)* 9(13)= 42(13),因为,在十三进制中,42 = 4 * 13 + ...
- [GodLove]Wine93 Tarining Round #8
比赛链接: http://vjudge.net/contest/view.action?cid=47644#overview 比赛来源: 2012 ACM/ICPC Asia Regional Tia ...
- HDU4278
Faulty Odometer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
随机推荐
- 在 Selenium 中让 PhantomJS 执行它的 API
from selenium import webdriver driver = webdriver.PhantomJS() script = "var page = this; page.o ...
- Chrome自带恐龙小游戏的源码研究(三)
在上一篇<Chrome自带恐龙小游戏的源码研究(二)>中实现了云朵的绘制和移动,这一篇主要研究如何让游戏实现昼夜交替. 昼夜交替的效果主要是通过样式来完成,但改变样式的时机则由脚本控制. ...
- 4.锁--并行编程之条件变量(posix condition variables)
在整理Java LockSupport.park()的东东.看到了个"Spurious wakeup".又一次梳理下. 首先来个<UNIX环境高级编程>里的样例: [c ...
- Java过滤特殊字符
Java正则表达式过滤 1.Java过滤特殊字符的正则表达式----转载 java过滤特殊字符的正则表达式[转载] 2010-08-05 11:06 Java过滤特殊字符的正则表达式 关键字: j ...
- CentOS系统环境下安装MongoDB
(1)进入MongoDB下载中心:http://www.mongodb.org/downloads We recommend using these binary distributions (官方推 ...
- 如何在linux下解压缩rar格式的文件压缩包
##########################################################如何在linux下解压缩rar格式的文件压缩包#date:2014年2月15日22: ...
- CString 成员函数用法大全(转)
CString( );例:CString csStr; CString( const CString& stringSrc );例:CString csStr("ABCDEF中文12 ...
- 在做RTSP摄像机H5无插件直播中遇到的对接海康摄像机发送OPTIONS心跳时遇到的坑
我们在实现一套EasyNVR无插件直播方案时,选择了采用厂家无关化的通用协议RTSP/Onvif接入摄像机IPC/NVR设备,总所周知,Onvif是摄像机的发现与控制管理协议,Onvif用到的流媒体协 ...
- 常用脚本--查看死锁和阻塞usp_who_lock(转)
USE [master] GO /****** Object: StoredProcedure [dbo].[sp_who_lock] Script Date: 02/07/2014 11:51:24 ...
- JS之字符串与JSON转换
JS之字符串转换JSON 1.eval 古老的方式 function strToJson(str){ var json = eval('(' + str + ')'); return json; ...