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)个整数, ...
随机推荐
- jquery调用asp.net 页面后台的实现代码
先创建一个aspx页面编写一个客户端控件<input type="button" id="AjaxDemo" value="AjaxDemo&q ...
- Quartz.NET持久化
Quartz.NET所用到的数据库表结构 官方提供的各种数据库脚本:https://github.com/quartznet/quartznet/tree/master/database/tables ...
- SQL 分页实现
--通用分页 ALTER PROCEDURE [dbo].[Sys_Pagination_1] @tblName VARCHAR(2000) , -- 表名 @strGetFields VARCHAR ...
- 【干货】JavaScript DOM编程艺术学习笔记10-12【完】
十.用JavaScript实现动画效果 鼠标放到链接上,每次只显示图片的一小部分,加快加载速度. js: function prepareSlideshow(){ //对象检测 if(!documen ...
- vue-cli建立的项目如何在手机端运行以及如何用charles来抓包
刚开始自己在config文件夹下的index.js中的dev下的host写成的是localhost,但是发现自己不能在手机端访问,并且也不可以在charles进行抓包处理,后来把localhost改成 ...
- https验证新发现-老知识
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier); 可以设置https全局的域名校验规则 HttpsURLConnecti ...
- ECLIPSE 取消自动更新
经常遇到一开eclipse 时,一直很卡的问题,发现是它一直尝试联网更新东西 ,如maven 所以解决办法 , eclipse 取消自动更新的方法: 1. window --> prefere ...
- Java JDBC链接Oracle数据库
package com.test.test; import java.io.FileInputStream;import java.io.FileNotFoundException;import ja ...
- Python对Excel操作详解
Python对Excel操作详解 文档摘要: 本文档主要介绍如何通过python对office excel进行读写操作,使用了xlrd.xlwt和xlutils模块.另外还演示了如何通过Tcl ...
- pta 编程题15 列出连通集
其它pta数据结构编程题请参见:pta 题目 题目要求分别以深度优先搜索和广度优先搜索输出图的连通集. 广度优先搜索要用到队列,先回顾一下循环队列: struct QNode { int* Data; ...