1058 A+B in Hogwarts

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,10​7​​], 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
 #include<cstdio>
 #include<iostream>
 using namespace std; 

 int main()
 {
 	int G,S,K;
 	int Gs=0,Ss=0,Ks=0;
 	for(int i=0;i<2;i++)
 	{
 		scanf("%d.%d.%d",&G,&S,&K);
 		Gs+=G;
 		Ss+=S;
 		Ks+=K;
	 }
	 if(Ks>=29)
	 {
	 	Ss=Ss+Ks/29;
	 	Ks=Ks%29;

	 }
	 if(Ss>=17)
	 {
	 	Gs=Gs+Ss/17;
	 	Ss=Ss%17;

	 }
	 printf("%d.%d.%d",Gs,Ss,Ks);
 	return 0;
 }

PAT甲级——1058 A+B in Hogwarts的更多相关文章

  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甲级——A1058 A+B in Hogwarts

    If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- a ...

  4. PAT 1058 A+B in Hogwarts

    1058 A+B in Hogwarts (20 分)   If you are a fan of Harry Potter, you would know the world of magic ha ...

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

  6. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  7. PAT甲级题分类汇编——计算

    本文为PAT甲级分类汇编系列文章. 计算类,指以数学运算为主或为背景的题. 题号 标题 分数 大意 1058 A+B in Hogwarts 20 特殊进制加法 1059 Prime Factors ...

  8. PAT甲级题分类汇编——序言

    今天开个坑,分类整理PAT甲级题目(https://pintia.cn/problem-sets/994805342720868352/problems/type/7)中1051~1100部分.语言是 ...

  9. PAT 甲级真题题解(1-62)

    准备每天刷两题PAT真题.(一句话题解) 1001 A+B Format  模拟输出,注意格式 #include <cstdio> #include <cstring> #in ...

随机推荐

  1. BZOJ [Scoi2010]游戏

    题解: 解法一:建立图论模型,发现只要联通块中有环则这个联通块中的值都可以被攻击到 如果是树,则只能攻击size-1个 解法二:二分图匹配,二分答案,看看是否能攻击到mid #include<i ...

  2. JAVA调用FFMpeg进行转码等操作

    直接上代码: public abstract class FFmpegUtils { FFmpegUtils ffmpegUtils; ; String timeLength = "&quo ...

  3. Ubuntu Teamviewer安装使用

    关于Ubuntu环境下teamviewer的安装(亲测可用-) 以下内容均转自:https://blog.csdn.net/weixin_41887832/article/details/798329 ...

  4. git push报错! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://gitee.com/XXX.git

    git pull origin master --allow-unrelated-histories  //把远程仓库和本地同步,消除差异 git add . git commit -m"X ...

  5. axios 等待同步请求用法及多请求并发

    axios等待同步请求 直接上代码 首先在函数中返回一个Promise对象,在调用函数使用同步函数,调用目标函数使用await等待即可 参考http://www.cnblogs.com/cckui/p ...

  6. 杂记 -- 关于less在vue项目中的使用

    1.安装less,less-loader npm install less less-loader --save 2.配置wepack.js(vue3+版本中不用自己设置) //添加less路径模块 ...

  7. Java之多线程方式一(继承Thread类)

    /** * 多线程的创建,方式一:继承于Thread类 * 1. 创建一个继承于Thread类的子类 * 2. 重写Thread类的run() --> 将此线程执行的操作声明在run()中 * ...

  8. MySQL笔记(二)——查询数据

    数据库管理系统的一个最重要的功能就是数据查询,数据查询不应只是简单的查询数据库中存储的数据,还应该是根据需要对数据进行筛选,以及确定数据以什么样的格式显示.本篇笔记主要介绍单表查询,子查询,连接查询. ...

  9. 两个tomcat使用同一个jvm可能会出错

    如果两个tomcat中的项目的某些类具有完全相同的包路径和类名的话,jvm可能会“弄混”这两个类,所以一般要求包名“必须”唯一. 当然,如果两个类中的代码和import的类完全一样,弄混了也就弄混了, ...

  10. 计量经济与时间序列_ACF与PACF标准差(均标准误)的计算(含代码)

    1   我们对于acf和pacf值计算完毕之后,在需要计算两个数值的标准差. 2   acf和pacf的标准差计算略有不同.acf的标准差是一个移动过程,而pacf是一个相对固定过程. 3   我们继 ...