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 ...
随机推荐
- GPU 、APU、CUDA、TPU、FPGA介绍
购买显卡主要关注:显存.带宽和浮点运算数量 GPU :图形处理器(英语:Graphics Processing Unit,缩写:GPU),又称显示核心.视觉处理器.显示芯片,是一种专门在个人电脑. ...
- 洛谷 P1020 导弹拦截
题目传送门 解题思路: 其实就是求一遍最长不上升子序列和最长上升子序列 AC代码: #include<iostream> #include<cstdio> #include&l ...
- BZOJ 2285 [Sdoi2011]保密
题解: 求比值用分数规划,单个求太慢了套整体二分 然后求二分图最小割 // luogu-judger-enable-o2 #include<iostream> #include<cs ...
- 毕设问题 ---链接Dreamweaver和eclipse
在eclipse里面新建站点 https://blog.csdn.net/Slash_youth 我是一个搬运工 哈哈哈
- java AES加解密
AES加解密工具类 package com.yan.demo; import org.apache.commons.lang3.StringUtils; import sun.misc.BASE64D ...
- 1-4 无监督学习(Unsupervised Learning)
无监督学习定义: [无监督学习]中没有任何的标签或者是有相同的标签或者就是没标签.所以我们已知数据集,却不知如何处理,也未告知每个数据点是什么.别的都不知道,就是一个数据集.你能从数据中找到某种结构吗 ...
- SQL基础教程(第2版)第6章 函数、谓词、CASE表达式:练习题
END) AS low_price, END) AS mid_price, END) AS high_price FROM Product; 6_2.sql
- Nginx和php交互的两种方式
Unix socket 也叫IPC socket 也就是进程间通信套接字用于同一台主机上的不同进程间交换数据 TCP socket IP socket要利用主机的传输层(tcp),可以用于同一台主机 ...
- 第二季第六天 part2 css动画
transition:background 2s,width 3s(第二个参数为变化时间) 1s(第三个参数为延迟时间): class:hover {} 伪类,鼠标移上去一个变化 <img ...
- MySQL--索引和外键
来自:http://www.jb51.net/article/32149.htm 1.添加PRIMARY KEY(主键索引) ALTER TABLE `table_name` ADD PRIMARY ...