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. windows平台RSA密钥生成

    1.安装openssl工具 下载安装openssl工具,执行安装目录bin下的"openssl.exe",执行后会弹出命令窗口. 2.生成私钥 在命令窗口输入“genrsa -ou ...

  2. python_反射——根据字符串获取模块中的属性

    1.获取当前模块中的属性 class Person(object): def __init__(self,name,age): self.name = name self.age = age p = ...

  3. ServletRequest、 HttpServletRequest、Request的联系与区别

    一. servlet理论上可以处理多种形式的请求响应形式 http只是其中之一 所以HttpServletRequest HttpServletResponse分别是ServletRequest和Se ...

  4. 使用 IDEA 打包spring cloud 成 jar在ubuntu 中运行

    1.  打开终端 termial   ,  使用 mvn  install  . 如果提示  mvn 不是xx 命令 ; 2 则需要配置环境变量  :  path :     C:\Program F ...

  5. 01_Tutorial 1: Serialization 序列化

    1.序列化 1.官方教程 https://q1mi.github.io/Django-REST-framework-documentation/tutorial/1-serialization_zh/ ...

  6. 40、扩展原理-BeanDefinitionRegistryPostProcessor

    40.扩展原理-BeanDefinitionRegistryPostProcessor BeanDefinitionRegistryPostProcessor extends BeanFactoryP ...

  7. javascript/Jquery 将字符串转换成变量名

    var a = ['a', 'b', 'c'] var obj = {} for(i = 0; i < a.length; i++){ obj[a[i]] = "abc" + ...

  8. git merge 及 git rebase的区别

    Git上合并代码有git merge 及 git rebase 两种方式. 前置知识点 Master分支:首先,代码库应该有一个.且仅有一个主分支.所有提供给用户使用的正式版本,都在这个主分支上发布. ...

  9. RS-232串口通信简介

    1969年,美国电子工业协会将RS-232定为串行通信接口的电器标准,该标准定义了数据终端设备DTE(Date Teriminal Equipment)与数据通信设备DCE(Data Communic ...

  10. luogu 1712

    按区间长度降序排序维护区间指针 [l, r],第 l ~ r 条线段 表示当前区间可以满足条件那么 r 后移一定不是更优的因此 l 前移,使得 r 后移过程中取最小值更新 answer #includ ...