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 分) (简单题)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. PAT甲级:1136 A Delayed Palindrome (20分)

    PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...

  4. 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 ...

  5. PAT 甲级 1054 The Dominant Color (20 分)

    1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 0、Python学习路线

    阶段一.Python语言(熟练掌握Python多线程并发编程技术,可以编写爬虫程序和语音识别软件.) 1.1 基础语法 1.1.1 python概述     1.1.2 数据的存储     1.1.3 ...

  2. MySQL之left jion 、 right jion 和inner jion 的区别和使用方法

    left jion   左联结 right jion 右联结 inner jion 等值联结 create table teacher( tid ) primary key auto_incremen ...

  3. vue 传入一个对象的所有属性

  4. ask confirm shell

    #/bin/bash BASEDIR=$(cd $() && pwd) cd $BASEDIR>/dev/null usage="Usage: $0 -o/--org ...

  5. <c:set> 标签

    <c:set> 标签 JSP 标准标签库 <c:set>标签用于设置变量值和对象属性. <c:set>标签就是<jsp:setProperty>行为标签 ...

  6. 洛谷P1991 无线通讯网【最小生成树】

    题目:https://www.luogu.org/problemnew/show/P1991 题意:有p个点的坐标,可以有s个点使得这s个点之间可以无限制通信. 要使所有点之间两两有通信的路径(可以是 ...

  7. DNSMAQ 搭建 DNS 服务

    DNSmasq是一个小巧且方便地用于配置DNS和DHCP的工具,适用于小型网络,它提供了DNS功能和可选择的DHCP功能.自己搭建公共DNS更加灵活,如果是在本地搭建,还可以大幅提高解析速度. 相比较 ...

  8. IDEA控制台中文乱码解决

    关于IDEA中文乱码的解决方法,如下. 1.打开idea安装目录,选择 打开文件,末尾添加-Dfile.encoding=UTF-8 2.打开IntelliJ IDEA>File>Sett ...

  9. Java链接Redis时出现 “ERR Client sent AUTH, but no password is set”

    Java链接Redis时出现 “ERR Client sent AUTH, but no password is set” 异常的原因及解决办法. [错误提示] redis.clients.jedis ...

  10. 学生管理系统——数据库、java基础

    1.项目分层 view层:视图层 controller层:控制层 service层:业务层 dao层:数据库访问层 domain:实体包 tools:工具类 2.jar包 3.配置文件 4.程序设计 ...