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 ...
随机推荐
- 【深入JAVA EE】Spring配置文件解析
在阅读的过程中有不论什么问题,欢迎一起交流 邮箱:1494713801@qq.com QQ:1494713801 一.Spring头信息 Spring配置文件的头部信息通常是固定不变的.但每个标 ...
- Unable to save settings: Failed to save settings. Please restart PyCharm解决
将工程的.ideas目录删掉,重启pycharm即可.
- linux下proc里关于磁盘性能的参数(转)
我们在磁盘写操作持续繁忙的服务器上曾经碰到一个特殊的性能问题.每隔 30 秒,服务器就会遇到磁盘写活动高峰,导致请求处理延迟非常大(超过3秒).后来上网查了一下资料,通过调整内核参数,将写活动的高峰分 ...
- jquery Jsonp的使用
<script type="text/javascript"> $(function(){ $.ajax({ url:"test", jsonpCa ...
- AWS:4.VPC
主要介绍 1.Amazon混合云 2.将EC2加入VPC 3.VPC经典场景 4.VPC安全保障 Amazon混合云 : 在公有云的基础上创建私有云 VPC概念 VPC(VPC Virtual Pri ...
- 小程序的生命周期 launchApp
https://developers.weixin.qq.com/miniprogram/dev/api/launchApp.html?search-key=生命周期 launchApp(OBJECT ...
- 如果数据需要被多个应用程序消费的话,推荐使用 Kafka,如果数据只是面向 Hadoop 的,可以使用 Flume
https://www.ibm.com/developerworks/cn/opensource/os-cn-kafka/index.html Kafka 与 Flume 很多功能确实是重复的.以下是 ...
- CF148D. Bag of mice(概率DP)
D. Bag of mice time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- VIM中使用tab键自动完成(vim tab键自动补全 )插件supertab
supertab.vmb 这个插件好好用, Tab自动补全 http://www.vim.org/scripts/script.php?script_id=1643 安装步骤: 1.下载 supert ...
- API的理解和使用——集合
集合类型的命令及时间复杂度 区间 命令 功能 时间复杂度 集合内 sadd key element [element ... ] 添加元素 O(k),k是元素个数 srem key elemen ...