PAT 甲级 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], Sickle is an integer in [0, 17), and Knut 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对换一个Galleon,29个Knut对换一个Sickle。根据Galleon.Sickle.Knut的方式相加A和B
分析:把A和B都化为Knut的形式,然后相加,最后转换为Galleon.Sickle.Knut的形式。
AC代码:
#include<iostream>
using namespace std;
int a1,b1,c1,a2,b2,c2;
int main(){
scanf("%d.%d.%d %d.%d.%d",&a1,&b1,&c1,&a2,&b2,&c2);
a1+=a2;
b1+=b2;
c1+=c2;
int x=c1/;
c1-=x*;
b1+=x;
x=b1/;
b1-=x*;
a1+=x;
printf("%d.%d.%d",a1,b1,c1);
return ;
}
PAT 甲级 1058 A+B in Hogwarts (20 分) (简单题)的更多相关文章
- 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 ...
- 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 h ...
- PAT甲级:1136 A Delayed Palindrome (20分)
PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...
- PAT甲级——1058 A+B in Hogwarts
1058 A+B in Hogwarts If you are a fan of Harry Potter, you would know the world of magic has its own ...
- PAT 甲级 1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...
- PAT 甲级 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
- PAT 甲级 1005 Spell It Right (20 分)
1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all th ...
- PAT 甲级 1031 Hello World for U (20 分)(一开始没看懂题意)
1031 Hello World for U (20 分) Given any string of N (≥) characters, you are asked to form the char ...
- PAT 甲级 1023 Have Fun with Numbers (20 分)(permutation是全排列题目没读懂)
1023 Have Fun with Numbers (20 分) Notice that the number 123456789 is a 9-digit number consisting ...
随机推荐
- windows平台RSA密钥生成
1.安装openssl工具 下载安装openssl工具,执行安装目录bin下的"openssl.exe",执行后会弹出命令窗口. 2.生成私钥 在命令窗口输入“genrsa -ou ...
- 7月新的开始 - Axure学习06 - 母版的使用
母版的使用 主导航.底部.在很多页面上都是一样的: 如果在每一个页面都写一次的化.话.是非常浪费时间的,为了方便.可以使用母版: 母版可以帮助我们将一些元素重复利用,既可以保证页面的统一性.还可以节省 ...
- uoj#67 新年的毒瘤【Tarjan】
题目:http://uoj.ac/problem/67 题意:n个节点m条边的图,删除某个节点及他相连的所有边之后,剩下的图就成了一棵树.找出所有这样的节点. 思路:上次去清华面试的B题,当时就是在瞎 ...
- python - Flask 基础 - 蓝图( Blueprint )(2)
""" 蓝图:为开发者提供的目录结构 - 使用: 1. 根目录创建一个跟项目名一样的文件 - 创建后第一步,在这个文件夹中添加一个 __init__.py 的配置文件 - ...
- Spring Data JPA 提供的各种Repository接口作用
各种Repository接口继承关系: Repository : public interface UserRepository extends Repository<User, Integer ...
- nginx配置url伪静态
rewrite 规则 定向路径 重写类型; 举例: rewrite (.*)/web/(.*)-(.*)-(.*).html$ $1/web/index.php?r=$2/$3/$4 last; ...
- HTML 003 元素
HTML 元素 HTML 文档由 HTML 元素定义. HTML 元素 开始标签 * 元素内容 结束标签 * <p> 这是一个段落 </p> <a href=" ...
- AtCoder Beginner Contest 133
目录 Contest Info Solutions A. T or T B.Good Distance C. Remainder Minimization 2019 D. Rain Flows int ...
- Educational Codeforces Round 55 题解
题解 CF1082A [Vasya and Book] 史上最难A题,没有之一 从题意可以看出,翻到目标页只有三种办法 先从\(x\)到\(1\),再从\(1\)到\(y\) 先从\(x\)到\(n\ ...
- scrapy 分布式爬虫- RedisSpider
爬去当当书籍信息 多台机器同时爬取,共用一个redis记录 scrapy_redis 带爬取的request对象储存在redis中,每台机器读取request对象并删除记录,经行爬取.实现分布式爬虫 ...