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(Galleonis an integer in [0,107],Sickleis an integer in [0, 17), andKnutis 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 ...
随机推荐
- 虚拟机体验NAS私人云全揭秘:序言——虚拟机体验NAS私人云缘由
"世界在新冠肺炎疫情后将永远改变",对于2020春天在全球蔓延的新冠肺炎疫情,美国前国务卿基辛格做了这样的评价.确实,也改变了我们.春节期间,本着少添乱的原则,响应国家号召,自我隔 ...
- MySQL学习之正则表达式篇
正则表达式(REGEXP) 1.简介 正则表达式是用来匹配列值的特殊字符集合,许多领域都有涉及, MySQL使用的正则表达式仅为其一个小小的子集. 2.基本字符匹配 2.1筛选包含特定字符串的信息 / ...
- leetcode-0101 对称二叉树
题目地址 https://leetcode-cn.com/problems/symmetric-tree/ 1.递归 本题最简单的思路是递归,可以假设两棵一模一样的树在进行镜像对比.他们之间的关系满足 ...
- ASP.Net内置对象之网页之间传参(一)
Response对象 主要运用于数据从服务器发送到浏览器,可以输出数据.页面跳转.各个网页之间传参数等操作. 以下讲解几个常用例子: 在页面中输出数据 主要通过Write .WriteFile方法输出 ...
- 随笔之——浮动(float)的影响及其清除、、clear与overflow-hidden清除float的不同!!!
一.浮动(float)对内联元素的影响. 1.我们都知道,内联元素(例如:span/img/input...)在正常情况下不可以对其设置宽高的,它的大小之只和它内部内容的多少有关. 我们怎样才可以对其 ...
- 9个小技巧让你的 if else看起来更优雅
if else 是我们写代码时,使用频率最高的关键词之一,然而有时过多的 if else 会让我们感到脑壳疼,例如下面这个伪代码: 是不是很奔溃?虽然他是伪代码,并且看起来也很夸张,但在现实中,当我们 ...
- atom 之 前端必备插件
一. 语法支持 1. Language-label Ø ES2016.ESNext.JXS语法扩展 2. Language-postcss Ø Postcss语法高亮 二. 自动补全 1. Autoc ...
- 8种MySQL分页方法总结
这篇文章主要介绍了8种MySQL分页方法总结,小编现在才知道,MySQL分页竟然有8种实现方法,本文就一一讲解了这些方法,需要的朋友可以参考下 MySQL的分页似乎一直是个问题,有什么优化方法吗?网上 ...
- nodejs操作MySQL,mysql连接池及事务的使用
https://blog.csdn.net/jasnet_u/article/details/88605168
- Algorithm Exercises
汇总一些常见的算法题目,参考代码. 注:部分题目没有合适的oj地址 枚举 Perfect Cubes.Biorhythms.Counterfeit Dollar.EXTENDED LIGHTS OUT ...