1058 A+B in Hogwarts (20分)
1058 A+B in Hogwarts (20分)
题目:
If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it's easy enough." Your job is to write a program to compute A+B where A and B are given in the standard form of
Galleon.Sickle.Knut
(Galleon
is an integer in [0,107],Sickle
is an integer in [0, 17), andKnut
is an integer in [0, 29)).Input Specification:
Each input file contains one test case which occupies a line with A and B in the standard form, separated by one space.
Output Specification:
For each test case you should output the sum of A and B in one line, with the same format as the input.
Sample Input:
3.2.1 10.16.27
Sample Output:
14.1.28
题意:
17 Sickle = 1 Galleon ; 29 Knuts = 1 Sickle
例子:
3.2.1 + 10.16.27 = 13.18.28 = 14.1.28
题解:
#include <cstdio>
int main() {
int ag,as,ak,bg,bs,bk,g,s,k;
scanf("%d.%d.%d %d.%d.%d",&ag,&as,&ak,&bg,&bs,&bk);
g = ag + bg;
s = as + bs;
k = ak + bk;
if(k >= 29) s += (k / 29), k %= 29;
if(s >= 17) g += (s / 17), s %= 17;
printf("%d.%d.%d",g,s,k);
return 0;
}
1058 A+B in Hogwarts (20分)的更多相关文章
- PAT 甲级 1058 A+B in Hogwarts (20 分) (简单题)
1058 A+B in Hogwarts (20 分) If you are a fan of Harry Potter, you would know the world of magic ha ...
- PAT Advanced 1058 A+B in Hogwarts (20 分)
If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- a ...
- 【PAT甲级】1058 A+B in Hogwarts (20 分)
题意: 输入两组,每组三个非负整数A,B,C(A<=1e7,B<17,C<29),输出相加的和.(类似个位上29进制,十位上17进制运算) AAAAAccepted code: #d ...
- 1058 A+B in Hogwarts (20分)(水)
If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- a ...
- 1058 A+B in Hogwarts (20)
#include <stdio.h> int main() { ]; ]; ],&ans1[],&ans1[],&ans2[],&ans2[],&a ...
- PAT (Advanced Level) 1058. A+B in Hogwarts (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT甲题题解-1058. A+B in Hogwarts (20)-大水题
无语,这种水题还出,浪费时间,但又不得不A... #include <iostream> #include <cstdio> #include <algorithm> ...
- 1058 A+B in Hogwarts (20 分)
1058 A+B in Hogwarts (20 分) If you are a fan of Harry Potter, you would know the world of magic has ...
- pat 1058 A+B in Hogwarts(20 分)
1058 A+B in Hogwarts(20 分) If you are a fan of Harry Potter, you would know the world of magic has i ...
随机推荐
- 4.加密与token(node+express)
一. 敏感数据加密1.安装并引入中间件 npm install utility const utils = require('utility')2.加密方法 function ...
- [javascript] jquery的父子兄弟节点查找
jQuery.parent(expr) 找父亲节点,可以传入expr进行过滤,比如$("span").parent()或者$("span").parent(&q ...
- 推荐一个小而美的Python代码格式化工具
代码可读性是评判代码质量的标准之一,有一个衡量代码质量的标准是 Martin 提出的 “WFT” 定律,即每分钟爆出 “WTF” 的次数.你在读别人代码或者做 Code Review 的时候有没有 “ ...
- TensorFlow keras vgg16net的使用
from tensorflow.python.keras.applications.vgg16 import VGG16,preprocess_input,decode_predictions fro ...
- openssl查看证书细节 [转载]
openssl x509部分命令 打印出证书的内容: openssl x509 -in cert.pem -noout -text 打印出证书的系列号 openssl x509 -in cert.pe ...
- Windows API Index
https://docs.microsoft.com/en-us/windows/desktop/apiindex/windows-api-list
- zookeeper笔记(一)
title: zookeeper笔记(一) zookeeper 安装简记 解压文件 $ tar -zxvf zookeeper-3.4.10.tar.gz -C 安装目录 创建软连接(进入安装目录) ...
- 【小技巧】【App store切换为中文】
为什么80%的码农都做不了架构师?>>> 贡献作者 -[XJDomain]博客XJ: https://my.oschina.net/shengbingli/blogGitHub ...
- Netty(五):ServerBootstrap启动流程
这篇文章主要是对ServerBootstrap启动流程做一个梳理,方便我们串联起各个类,同时也对主要的一些类有个大概的印象,方便之后逐个类的深入学习. 本篇文章不在具体贴出代码,而是对整个启动流程画了 ...
- P1460 健康的荷斯坦奶牛 Healthy Holsteins (简单的dfs)
题目描述 农民JOHN以拥有世界上最健康的奶牛为傲.他知道每种饲料中所包含的牛所需的最低的维他命量是多少.请你帮助农夫喂养他的牛,以保持它们的健康,使喂给牛的饲料的种数最少. 给出牛所需的最低的维他命 ...