PTA(Basic Level)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
思路
- 题意就是
G.S.K形式的货币运算,公式为1G=17S, 1S=29K,按照这个规则相加取余就好了
代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int g1, s1, k1;
int g2, s2, k2;
cin >> g1 >> s1 >> k1 >> g2 >> s2 >> k2;
int g, s, k;
g = g1 + g2;
s = s1 + s2;
k = k1 + k2;
int t = k;
t = k % 29;
s += k / 29;
t = s % 17;
g += s / 17;
cout << g << "." << s << "." << k;
return 0;
}
引用
https://pintia.cn/problem-sets/994805342720868352/problems/994805416519647232
PTA(Basic Level)1058.A+B in Hogwarts的更多相关文章
- PTA(Basic Level)1006.Sign In and Sign Out
At the beginning of every day, the first person who signs in the computer room will unlock the door, ...
- 来自PTA Basic Level的三只小野兽
点我阅读原文 最近利用闲暇时间做了一下 PTA Basic Level[1] 里的题,里面现在一共有 95 道题,这些题大部分很基础,对于刷倦了 leetcode 的小伙伴可以去里面愉快的玩耍哦. 这 ...
- PTA(Basic Level)1020.月饼
月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼.现给定所有种类月饼的库存量.总售价.以及市场的最大需求量,请你计算可以获得的最大收益是多少. 注意:销售时允许取出一部分库存.样 ...
- PTA(Basic Level)1057.数零壹
给定一串长度不超过 105 的字符串,本题要求你将其中所有英文字母的序号(字母 a-z 对应序号 1-26,不分大小写)相加,得到整数 N,然后再分析一下 N 的二进制表示中有多少 0.多少 1.例如 ...
- PAT (Advanced Level) 1058. A+B in Hogwarts (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PTA(Basic Level)-1002 写出这个数
一 1002 写出这个数 读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字. 输入格式: 每个测试输入包含 1 个测试用例,即给出自然数 n 的值.这里保证 n 小于 1010 ...
- PTA(Basic Level)-1076 Wifi密码
一 题目介绍: 现将 wifi 密码设置为下列数学题答案:A-1:B-2:C-3:D-4.本题就要求你写程序把一系列题目的答案按照卷子上给出的对应关系翻译成 wifi 的密码.这里简单假设每道 ...
- PTA(Basic Level)1039.到底买不买
小红想买些珠子做一串自己喜欢的珠串.卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖.于是小红要你帮忙判断一下,某串珠子里是否包含了全部自己想要的珠子?如果是,那么告诉她有多少多余的珠子 ...
- PTA(Basic Level)1033.旧键盘打字
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及坏掉的那些键,打出的结果文字会是怎样? 输入格式: 输入在 2 行中分别给出坏掉的那些键.以及应该输入 ...
随机推荐
- codevs 2977 二叉堆练习1x
时间限制: 10 s 空间限制: 32000 KB 题目等级 : 白银 Silver 题目描述 Description 已知一个二叉树,判断它是否为二叉堆(小根堆) 输入描述 Input ...
- 『ZJOI2019 D2T2』语言
~~ 话说,本题考场想出三只\(log\)的暴力做法,被卡成暴力了.~~ 题目分析 首先考虑枚举每一个点,计算这个点可以和多少点进行交易. 将所有经过该点的路径\(s,t\)拿出,那么这些极远的\(s ...
- jquery判断元素是否可见隐藏
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta nam ...
- 微信小程序“反编译”
https://www.jianshu.com/p/ad8f417219e9 https://segmentfault.com/a/1190000018592740?utm_source=tag-ne ...
- 3.开始使用Spring Cloud实战微服务
开始使用Spring Cloud实战微服务 3.1. Spring Cloud实战前提 3.1.1. 需要的技术储备 语言方面:可以使用Java.scala.Groo ...
- HTTP服务器(2)
import socket import re import multiprocessing def service_client(new_socket): """为这个 ...
- Java - 自动装箱与拆箱详解
1.装箱与拆箱 装箱,将基本数据类型转为包装类型.拆箱,将包装类型转为基本数据类型. // Byte, Short, Integer, Long, Double, Float, Boolean, Ch ...
- SRS之SrsRtmpConn::stream_service_cycle详解
首先使用 obs 推流符合如下流程:参考自 Hanvision Makito X cann't publish to SRS.. FFMPEG: C/S: Handshake C: ConnectAp ...
- Telnet/SSH 客户端
一.WinSCP linux 与 windows 间传递文件.可以与 putty 配合使用. 官网提供便携版下载:https://winscp.net/eng/downloads.php 支持中文,语 ...
- 一、基础篇--1.2Java集合-HashMap和ConcurrentHashMap的区别【转】
http://www.importnew.com/28263.html 今天发一篇”水文”,可能很多读者都会表示不理解,不过我想把它作为并发序列文章中不可缺少的一块来介绍.本来以为花不了多少时间的,不 ...