PAT A1058 A+B in Hogwarts

这篇具有很好参考价值的文章主要介绍了PAT A1058 A+B in Hogwarts。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1058 A+B in Hogwarts

分数 20

作者 CHEN, Yue

单位 浙江大学

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

 文章来源地址https://www.toymoban.com/news/detail-451135.html

#include <iostream>

using namespace std;

int main()
{
    int tran[] = {100000000, 17, 29};
    
    int s[3][3];
    
    for(int i=0; i<2; ++i)
        scanf("%d.%d.%d", &s[i][0], &s[i][1], &s[i][2]);
    
    for(int i=2, d=0; i>=0; --i)
    {
        d += (s[0][i] + s[1][i]);
        s[2][i] = d % tran[i];
        d /= tran[i];
    }
    
    printf("%d.%d.%d\n", s[2][0], s[2][1], s[2][2]);
    
    return 0;
}

到了这里,关于PAT A1058 A+B in Hogwarts的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • PAT 1164 Good in C 测试点3,4

    个人学习记录,代码难免不尽人意。 When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows? Input Specification: Each input file contains one test case. For each case, the first part gives the 26 capital English letters A-Z, each in a 7×5 matrix of C’s and .\\\'s. Then a sentence is given in a

    2024年02月09日
    浏览(54)
  • selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PAT

    selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH. Please see。。。 1. 查看本机Chrome浏览器版本 2. 去下载chromedriver 下载地址1(我登不上去): chromedriver.storage.googleapis.com/index.html 下载地址2: https://registry.npmmirror.com/binary.html?path=chromedriver/ 找到对

    2024年02月09日
    浏览(41)
  • selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT

    最近需要使用一下selenium,刚运行就报错了。。。 前提准备: 1.安装selenium 2.下载chrome对应版本的chromedriver 代码就是一个简单的demo: 运行报错: 网上说要把chromedriver放到环境变量,放进去还是报错!! 然后就直接看源码吧: 这个过程很繁琐,很枯燥,嫌废话连篇请直接翻到文

    2024年01月20日
    浏览(29)
  • Vulnhub: Hogwarts: Bellatrix靶机

    kali:192.168.111.111 靶机:192.168.111.228 端口扫描 访问80端口 查看源码,提示 ikilledsiriusblack.php 和文件包含的参数名 file ikilledsiriusblack.php 存在文件包含 可以包含ssh日志文件 /var/log/auth.log 写入webshell到ssh日志文件 执行命令 执行反弹shell 在 /var/www/html/c2VjcmV0cw== 目录中发现密码字典

    2024年02月10日
    浏览(22)
  • ES:先按相关性分数进行排序,分数相同时再按其他字段排序

    最近,在公司学习ES的使用,导师给了个题目,如何对一个文档先计算分数,用分数进行排序,在分数相同的情况下再按照别的字段(如时间)进行排序,为此,从来没接触过ES的我开启了艰难的学习之路 本文参考自 ES权威指南(中文版) 以下是目录: 相关性算分描述了一个

    2024年02月05日
    浏览(31)
  • PAT B1049

    题目 给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列 { 0.1, 0.2, 0.3, 0.4 },我们有 (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4) (0.3) (0.3, 0.4) (0.4) 这 10 个片段。 给定正整数数列,求出全部片段包含的所有的数之和。

    2024年02月02日
    浏览(25)
  • PAT 甲级【1010 Radix】

    本题范围long型(35)^10 枚举radix范围上限pow(n/a0,1/m)上,考虑上限加1.范围较大。使用二分查找枚举 代码如下 本页面将简要介绍二分查找,由二分法衍生的三分法以及二分答案。 二分查找(英语:binary search),也称折半搜索(英语:half-interval search)、对数搜索(英语:logar

    2024年02月08日
    浏览(27)
  • pat乙级1002

    关键思路: 大数输入问题 1010010100 用int和long long都是远远不够的,因此用字符数组来输入,然后再转换成整数 数字与拼音的转换 本题用最基本的方法,使用switch开关语句实现转换 拼音数字间有 1 空格,但一行中最后一个拼音数字后没有空格。 此类问题一般使用以下代码实

    2023年04月14日
    浏览(31)
  • NAT与PAT

        NAT(Nct.work Adldrnns Trans l at.i on)又称为网络地址转换,用于实规私不网络和公不网络之问的互访。 公有网络地址(以下简称公网地址)是指在互联网上全球唯一的IP地址。2019年11月26日,是人类互联网时代值得纪念的一-天,全球近43亿个IPv4地址己正式耗尽。 私有网络地址(以下简

    2024年02月11日
    浏览(30)
  • pat乙题1002

    笔记: 1.字符数组char s[]的长度用sizeof(), strlen() 字符串string s长度s.size()和s.length()都是求的实际的占位,不算0的 2.switch: 用一个显化记录的字符串不就行了。 3.把数字sum粘贴到字符串数组s 上 改:用动态字符串存入。 4.既然用的char s[],想把字符串里的数字加和,当然要用-‘

    2024年02月16日
    浏览(25)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包