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,107], 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 = 1 Galleon ; 29 Knuts = 1 Sickle

例子:

3.2.1 + 10.16.27 = 13.18.28 = 14.1.28

题解:

#include <cstdio>
int main() {
int ag,as,ak,bg,bs,bk,g,s,k;
scanf("%d.%d.%d %d.%d.%d",&ag,&as,&ak,&bg,&bs,&bk);
g = ag + bg;
s = as + bs;
k = ak + bk;
if(k >= 29) s += (k / 29), k %= 29;
if(s >= 17) g += (s / 17), s %= 17;
printf("%d.%d.%d",g,s,k);
return 0;
}

1058 A+B in Hogwarts (20分)的更多相关文章

  1. PAT 甲级 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 ha ...

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

  3. 【PAT甲级】1058 A+B in Hogwarts (20 分)

    题意: 输入两组,每组三个非负整数A,B,C(A<=1e7,B<17,C<29),输出相加的和.(类似个位上29进制,十位上17进制运算) AAAAAccepted code: #d ...

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

  5. 1058 A+B in Hogwarts (20)

    #include <stdio.h> int main() { ]; ]; ],&ans1[],&ans1[],&ans2[],&ans2[],&a ...

  6. PAT (Advanced Level) 1058. A+B in Hogwarts (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  7. PAT甲题题解-1058. A+B in Hogwarts (20)-大水题

    无语,这种水题还出,浪费时间,但又不得不A... #include <iostream> #include <cstdio> #include <algorithm> ...

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

  9. pat 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 has i ...

随机推荐

  1. 关于JS垃圾回收机制

    一.垃圾回收机制的必要性 由于字符串.对象和数组没有固定大小,所以当它们的大小已知时,才能对它们进行动态的存储分配.JavaScript程序每次创建字符串.数组或对象时,解释器都必须分配内存来存储那个 ...

  2. Couchdb 垂直权限绕过漏洞(CVE-2017-12635)漏洞复现

    couchdb简介: Apache CouchDB是一个开源的NoSQL数据库,专注于易用性和成为“完全拥抱web的数据库”.它是一个使用JSON作为数据存储格式,javascript作为查询语言,M ...

  3. 重装anaconda的记录,包含设置jupyter kernel

    anaconda安装记录 官网下载最新版 linux:sh xx.sh 注意不要敲太多回车,容易错过配置bash的部分,还要手动添加 (vim ~/.bashrc 手动添加新bash,卸载时也要删掉此 ...

  4. pytorch seq2seq闲聊机器人

    cut_sentence.py """ 实现句子的分词 注意点: 1. 实现单个字分词 2. 实现按照词语分词 2.1 加载词典 3. 使用停用词 "" ...

  5. python学习08排序算法举例

    '''''''''排序算法:前提是所有数按照从小到大的顺序排列.1.冒泡算法将第一数与第二个数比较大小,如果第一个数比第二个数大,则沉底(交换位置,使大数在小数后面,这个过程类似于大泡沉底的过程) ' ...

  6. 2019-2020-1 20199328《Linux内核原理与分析》第九周作业

    笔记部分 2019/11/12 14:45:44 从CPU和内存的角度看linux系统的运行 CPU角度:首先我们进行了系统调度,然后系统进入内核态,把信息压栈,然后我们进行进程管理,由于进入系统调用 ...

  7. 还在写CURD?试试这款基于mybatis-plus的springboot代码生成器

    目录 ⚡Introduction ✔️Release Features Quick Start Examples 1.Controller模板代码示例 2.Service模板代码示例 3.Servic ...

  8. [故障解决]图文:windows apache无法启用 端口被占用

    windows apache无法启用 端口被占用 1 XAMPP Error: Apache shutdown unexpectedly 无法启动apache,显示的log为: 2 查了一下端口, 通 ...

  9. 使nfs同步生效

    我们在使用nfs的时候会遇到往nfs server端写个文件,client需要很久才能生效,我们想让立刻生效有两种办法:1.mount -t nfs -o noac IP:/data/xxxx /xx ...

  10. RobotFrameWork 自动化环境搭建(基于 python3.6)

    一.需要安装的工具目录 安装 python3.6.0 我这里采用的是 python3.6 (目前慢慢市场在推广 python3.0 版本了) 安装 wxPython(Python 非常有名的一个GUI ...