A1058 A+B in Hogwarts (20)(20 分)
A1058 A+B in Hogwarts (20)(20 分)
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
AC代码
#include <stdio.h>
int main() {
int a[3], b[3], c[3];
scanf("%d.%d.%d %d.%d.%d", &a[0], &a[1], &a[2], &b[0], &b[1], &b[2]);
int carry = 0;//进位
c[2] = (a[2] + b[2]) % 29;//二号位结果
carry = (a[2] + b[2]) / 29;//进位
c[1] = (a[1] + b[1] + carry) % 17;//一号位结果(加上进位)
carry = (a[1] + b[1] + carry) / 17;//进位
c[0] = a[0] + b[0] + carry;//无限制,不必再处理进位了
printf("%d.%d.%d", c[0], c[1], c[2]);
return 0;
}
A1058 A+B in Hogwarts (20)(20 分)的更多相关文章
- 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 ...
- 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 ...
- MVC4 学习笔记 之 URL中存在编译的空格 20%20%
/Config/Edit/QQCC%20%20%20%20%20%20%20 原因是: 通过EF直接添加了空格? NO 是因为你的数据库字段设计问题,因为你当然设计如>:sID nchar(10 ...
- 2016年11月29日 星期二 --出埃及记 Exodus 20:20
2016年11月29日 星期二 --出埃及记 Exodus 20:20 Moses said to the people, "Do not be afraid. God has come t ...
- 安装nginx环境(含lua)时遇到报错ngx_http_lua_common.h:20:20: error: luajit.h: No such file or directory的解决
下面是安装nginx+lua环境时使用的相关模块及版本,ngx_devel_kit和lua-nginx-module模块用的都是github上最新的模块.并进行了LuaJIT的安装. #Install ...
- PAT A1058 A+B in Hogwarts (20)
AC代码 #include <cstdio> struct Money { long long Galleon, Sicklke, Knut; }A, B, Sum; void init( ...
- 做数据挖掘,就算发 20 几分的 CNS 子刊,也是垃圾!?--转载
关于数据挖掘发表文章,我们知道很多人是看不上.瞧不起.嗤之以鼻的.大抵是因为这些人平时只发 CNS 主刊,所以才认为通过数据挖掘这种用「别人的数据」或者叫「干实验」来发文章是“「垃圾」,没有什么价值. ...
- [C++]PAT乙级1012.数字分类 (20/20)
/* 1012. 数字分类 (20) 给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字: A1 = 能被5整除的数字中所有偶数的和: A2 = 将被5除后余1的数字按给出顺序进行交错求和, ...
- [C++]PAT乙级1008.数组元素循环右移问题 (20/20)
/* 1008. 数组元素循环右移问题 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 一个数组A中存有N(N>0)个整数, ...
随机推荐
- Java学习笔记--字符串和文件IO
1.Java中的字符串类和字符的表示 2.区分String,StringBuilder和StringBuffer 3.从命令行中给main方法传递参数 4.文件操作 1 Java中的字符串和字符 1. ...
- Java中的continue语句——通过示例学习Java编程(12)
作者:CHAITANYA SINGH 来源:https://www.koofun.com//pro/kfpostsdetail?kfpostsid=23 continue语句主要是用在循环代码块中.当 ...
- git从安装到应用的学习
本文内容是对廖雪峰老师Git教程做的笔记,外加一些自己的学习心得,还抱着学以致用的心态来实践一番 Git学习笔记 分布式版本控制与集中式版本控制的最大区别 集中式的版本控制,本地没有历史记录,完整的仓 ...
- GreenDao 使用知识小y
//关于 group by 的实现//--------------------XXXDao.queryBuilder().where(new WhereCondition.StringConditio ...
- 关于调用百度地图api在自己写的网页中实现和解决在https中正常显示
百度地图开发者:http://lbsyun.baidu.com/index.php?title=jspopular 我们打开百度地图开发者网站,注册一个百度账号,然后打开控制台,开始创建应用:(如果你 ...
- UVA - 1639 Candy (概率,精度)
X表示剩下的糖数量,如果最后打开的是p对应的盒子.划分:Xi表示剩下i个糖,最后一次选的概率为p, 前面的服从二项分布.根据全概率公式和期望的线性性,求和就好了. 精度处理要小心,n很大,组合数会很大 ...
- Linux yum安装
一.安装Apache软件步骤:1.安装 yum install httpd 2.启动,关闭 重启等命令systemctl start httpd.service(启动)systemctl restar ...
- Oracle 函数 之 Coalesce()、greatest()、least()
Coalesce().greatest().least() oracle比较一列的数据大小时,我们一般使用max()/min()函数,比较一行的最大值或者最小值时,使用函数Coalesce()/gre ...
- 问题004:如何在windows中打开命令行,有几种方法?
第一种方法:按快捷键 Win+R (run),然后运行框中输入cmd. 第二种方法:开始菜单-->运行-->然后运行框中输入cmd. 第三种方法:在附件当中,找命令行选项即可.
- 《转载》ASP动态iframe
原文:[ASP.NET]关于iframe的两个技巧 最近在给朋友写个网站,虽然不大,但是也碰到了一些问题.这篇就为解决ASP.NET中关于IFRAME的两个很现实的问题提供解决方法.PS:呵呵,又做了 ...