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 ...
随机推荐
- 并发编程大师系列之:CountDownLatch和Join
业务场景描述:假设一条流水线上有三个工作者:worker1,worker2,worker3.有一个任务的完成需要他们三者协作完成,worker3可以开始这个任务的前提是worker1和worker2完 ...
- 2018 南京网络预赛Sum ——莫比乌斯反演
题意 设 $f(n)$ 为 $n=ab$ 的方案数,其中 $a,b$ 为无平方因子数.求 $\displaystyle \sum_{i=1}^nf(i)$,$n \leq 2e7$. 分析 显然,可 ...
- Dao的扩展
题目: 1.查询所有学生记录,包含年级名称2.查询S1年级下的学生记录 一.项目目录 package com.myschool.entity; import java.util.ArrayList; ...
- 《论文翻译》Xception
目录 深度可分离网络-Xception 注释 1. 摘要 2. 介绍 3. Inception假设 4. 卷积和分离卷积之间的联系 4. 先验工作 5. Xception 架构 6. 个人理解 单词汇 ...
- Python3循环
Python中while语句的一般形式: while 判断条件: 语句 同样需要注意冒号和缩进,另外在Python中没有do…while循环 下面的实例计算1到100总和 ##calc.py n = ...
- luogu4208
P4208 [JSOI2008]最小生成树计数 题目描述 现在给出了一个简单无向加权图.你不满足于求出这个图的最小生成树,而希望知道这个图中有多少个不同的最小生成树.(如果两颗最小生成树中至少有一条边 ...
- 微信H5的video标签解决方案
https://github.com/cczw2010/weixin-video 偶尔发现了可以h5化的一种更适合的方式,一个有趣的属性 h5-page 已经更新
- 1、套按字及http基础知识之一
MAC地址:设备到设备之间通信时专用(从源主机到目标主机可能经由N台路由设备)4 IP地址:标记主机到主机之间通信时专用 TCP/UDP :提供进程地址 通过port number来标记 进程地址:用 ...
- (转)mysql更改数据目录
mysql 更改默认数据目录 http://www.cnblogs.com/chenny7/p/3642363.html 本文主要介绍在CentOS下通过yum命令安装MySQL之后,如何移动默认数据 ...
- checkbox取反
var qxs = document.getElementsByName("qx"); for(var i=0;i<qxs.length;i++){ var e=qxs[ ...