1058. A+B in Hogwarts (20)

时间限制
50 ms

内存限制
65536 kB

代码长度限制
16000 B

判题程序
Standard

作者
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

解析:简单题,代码如下:

#include <stdio.h>typedef struct
{int ga;int si;int kn;
} num;void Plus(num *pA, num *pB)
{num C;C.ga = pA->ga + pB->ga;C.si = pA->si + pB->si;C.kn = pA->kn + pB->kn;C.si += C.kn / 29;C.kn = C.kn % 29;C.ga += C.si / 17;C.si = C.si % 17;printf("%d.%d.%d\n", C.ga, C.si, C.kn);
}int main()
{num A, B;scanf("%d.%d.%d%d.%d.%d", &A.ga, &A.si, &A.kn, &B.ga, &B.si, &B.kn);Plus(&A, &B);return 0;
}

1058. A+B in Hogwarts (20)相关推荐

  1. 【PAT甲级 进位相加】1058 A+B in Hogwarts (20 分) C 全部AC

    题目 进位相加 题解 C #include<stdio.h> int main() {int a1, b1, c1;int a2, b2, c2;int a3, b3, c3;scanf( ...

  2. 1058 A+B in Hogwarts (20 分)_7行代码AC

    PAT甲级最优题解-->传送门 If you are a fan of Harry Potter, you would know the world of magic has its own c ...

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

  4. PAT甲级1058 A+B in Hogwarts :[C++题解]字符串,进制,简单

    文章目录 题目分析 题目链接 题目分析 不同进制进位. ac代码 #include<bits/stdc++.h> using namespace std;int main(){int a, ...

  5. 1058 A+B in Hogwarts

    笔记:和乙级的在霍格沃兹找零钱不同,这里不需要判断给出的两个数的大小,也没必要先都换算成最小的单位,可以直接从最低位开始加,如果超过该位的范围,则向上一位进一即可. #include<cstdi ...

  6. A+B in Hogwarts (20)

    水题 题目描述 If you are a fan of Harry Potter, you would know the world of magic has its own currency sys ...

  7. PAT甲级题目翻译+答案 AcWing(高精度)

    1002 A+B for Polynomials (25 分) 题意 :给两个多项式,输出两个多项式相加结果的系数和次数 思路 :用double数组记录多项式,正好数组下标是整数,系数是double ...

  8. 【最新合集】PAT甲级最优题解(题解+解析+代码)

    以下每道题均是笔者多方对比后, 思考整理得到的最优代码,欢迎交流! 共同成长哇.可以和博主比拼一下谁刷的更快~ 欢迎收藏.欢迎来玩儿 PAT题解目录 题号 标题 题解 分类 使用算法 1001 A+B ...

  9. 【PAT甲级】字符串处理及进制转换专题

    目录 字符串处理 PAT甲级 1001 A+B Format (20 分) PAT甲级1005 Spell It Right (20 分) PAT甲级1035 Password (20 分) PAT甲 ...

最新文章

  1. 如何建立自信心,不错!
  2. js hoisting -- 提升 学习笔记
  3. oracle段管理方式设为自动,oracle自动段管理ASSM笔记
  4. db2查最新值的前一天值_贵阳6月最新二手房房价出炉!快看你家房子值多少钱?...
  5. 句句真研—每日长难句打卡Day20
  6. 小波变换 分离影像低频部分_经济周期分析的强大工具——小波分析
  7. 不要把a href=当作按钮用
  8. idea怎么调试jsp页面_JSP+Servlet+C3P0+Mysql实现的YCU movies电影网站
  9. android go官方下载,dji go 4 app官网下载-DJI GO 4 安卓版v4.3.40-pc6智能硬件网
  10. 阿里云搭建MQTT物联网服务器
  11. android 音频子系统框架(一)
  12. 一般熟练盲打需要多久_如何学会盲打, 大概需要多长时间?
  13. python一键安装框架_《自拍教程76》Python 一键批量安装第三方包
  14. 【操作系统】线程栈如何分配
  15. 打开小猫咪之后,国内的网站打不开了,怎么办。原因是dns解析出了问题
  16. ios浏览器微信支付回调页面_iOS集成H5微信支付实现跳转与回调的解决方案
  17. 快速提取过火区域,卫星影像评估西昌山火方法初探
  18. 百度地图 --- 自定义标注点
  19. [ERP]ERP的核心管理思想
  20. Linux下Awk详解(转载)

热门文章

  1. spring mvc学习(37):JavaEE-JSP基础-EL表达式和JSTL标签库(Taglibs)
  2. 第六十二期:腾讯云发布“小程序·云开发十大优秀实践”:猫眼、唯品会等入选
  3. java学习(175):method类反射机制
  4. 物联网IoT接入技术分类以及华为OC平台特性
  5. java druid sqlite_springboot整合druid抛出dbType not support : sqlite异常
  6. vue-cli3全面配置详解
  7. 分时技术用户可以独占计算机资源,计算机基础第二章选择题(带答案修改版 )校过...
  8. 编译原理预测分析程序
  9. 解决ubuntu16.04 qt5.9.1无法输入中文
  10. 分治3--黑白棋子的移动