PAT甲级——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,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
#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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- PAT甲级题分类汇编——计算
本文为PAT甲级分类汇编系列文章. 计算类,指以数学运算为主或为背景的题. 题号 标题 分数 大意 1058 A+B in Hogwarts 20 特殊进制加法 1059 Prime Factors ...
- PAT甲级题分类汇编——序言
今天开个坑,分类整理PAT甲级题目(https://pintia.cn/problem-sets/994805342720868352/problems/type/7)中1051~1100部分.语言是 ...
- PAT 甲级真题题解(1-62)
准备每天刷两题PAT真题.(一句话题解) 1001 A+B Format 模拟输出,注意格式 #include <cstdio> #include <cstring> #in ...
随机推荐
- 3DES 原理
3DES的原理: 加密阶段:用密钥1加密->用密钥2解密->用密钥3加密 解密阶段:用密钥3解密->用密钥2加密->用密钥1解密 版权声明:本文为博主原创文章,未经博主允许不得 ...
- JZOJPJ-C 8/21题解
原题大战D1 吐槽: T1 \(O(N^2)\; N \leq 26\) N大时还要写高精, 可以增加难度 T2 不给范围 T3 居然没有完全卡掉 不对应该赞美出题人 T4 PJ考个四边形不等式?? ...
- Leetcode -- 两数之和Ⅰ
1. 两数之和 题目描述:给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那两个整数,并返回他们的数组下标. 示例:给定 nums = [2, 7, 11, 15 ...
- windows和ubuntu双系统设置开机默认系统
1.记住grub界面中windows的位置 我的界面如下:windows在第3行 2.选择进入ubuntu系统 3.打开终端,输入如下命令 sudo vim /etc/default/grub 4.看 ...
- [极客大挑战 2019]EasySQL
万能密码直接登陆得到flag admin' or 1=1 #
- h5-sessionStorage储存的使用
<!-- sessionStorage的使用:存储数据到本地.存储的容量5mb左右 1.这个数据本质是储存在当前页面的内存中 2.他的生命周期为关闭当前页面,关闭页面,数据会自动清楚 setTt ...
- POJ 1287 Networking【kruskal模板题】
传送门:http://poj.org/problem?id=1287 题意:给出n个点 m条边 ,求最小生成树的权 思路:最小生树的模板题,直接跑一遍kruskal即可 代码: #include< ...
- PAT Advanced 1092 To Buy or Not to Buy (20) [Hash散列]
题目 Eva would like to make a string of beads with her favorite colors so she went to a small shop to ...
- ajax使用json数组------前端往后台发送json数组及后台往前端发送json数组
1.引子 Json是跨语言数据交流的中间语言,它以键/值对的方式表示数据,这种简单明了的数据类型能被大部分编程语言理解.它也因此是前后端数据交流的主要方式和基础. 2.前端往后台传输json数据 第一 ...
- tensorflow从训练自定义CNN网络模型到Android端部署tflite
网上有很多关于tensorflow lite在安卓端部署的教程,但是大多只讲如何把训练好的模型部署到安卓端,不讲如何训练,而实际上在部署的时候,需要知道训练模型时预处理的细节,这就导致了自己训练的模型 ...