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. 【Mac】打开配置文件,添加/修改环境变量

    打开文件编辑器: 进入终端,输入open -e .bash_profile或者open -t ~/.bash_profile  打开profile文件 填写配置的环境变量: #示例代码 export ...

  2. POJ-2478-Farey Sequence(欧拉函数)

    链接: https://vjudge.net/problem/POJ-2478 题意: The Farey Sequence Fn for any integer n with n >= 2 i ...

  3. PHP yield占用内存测试

    function com($start) { $tmp = []; for($i=0; $i<300000; $i++){ $tmp[] = $i; } $end = memory_get_us ...

  4. UEFI分区损坏重建指南

    自从国庆假期发了这两篇博客后,我这个人就像是从博客园消失了一样,半个多月没更新..自从10月5号把UEFI分区删掉之后,我的电脑就因为没有引导,找不到系统而无法使用了.所以这篇博客,就分享一下我在这半 ...

  5. GreenPlum 数据备份与恢复

    GreenPlum数据备份与恢复gp_dump是GP并行备份的备份工具,在运行gp_dump的时候master与所有的segment节点都开始备份(standby节点和segment节点中的mirro ...

  6. 九.配置SMB共享(Samba共享)

    • Samba 软件项目 – 用途:为客户机提供共享使用的文件夹 – 协议:SMB(TCP 139).CIFS(TCP 445)  • 所需软件包:samba • 系统服务:smb   管理共享账号 ...

  7. 动态menu导航条以及treeview树

    1.menu表数据 2.在后台生成html内容后,前台利用nav-h.css生成menu导航条,利用Jquery的treeview插件生成menu树 前台coding: <!DOCTYPE ht ...

  8. learning scala generic classes

    package com.aura.scala.day01 object genericClasses { def main(args: Array[String]): Unit = { val sta ...

  9. K Simple question (第十届山东理工大学ACM网络编程擂台赛 正式赛)

    题解:素数筛+唯一分解定理 可以把素数筛那部分放到while之外,减小时间复杂度. #include <stdio.h> #include <stdlib.h> #includ ...

  10. spark源码之SparkContext

    SparkContext可以说是Spark应用的发动机引擎,Spark Drive的初始化围绕这SparkContext的初始化. SparkContext总览 sparkcontxt的主要组成部分 ...