A+B in Hogwarts (20)(模拟)
时间限制 1000 ms 内存限制 65536 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小)
题目描述
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)).
输入描述:
Each input file contains one test case which occupies a line with A and B in the standard form, separated by one space.
输出描述:
For each test case you should output the sum of A and B in one line, with the same format as the input.
输入例子:
3.2.1 10.16.27
输出例子:
14.1.28
题解:把进位转换模拟即可,水题
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a1,a2,a3,b1,b2,b3;
scanf("%d.%d.%d %d.%d.%d",&a1,&a2,&a3,&b1,&b2,&b3);
int sum1=0,sum2=0,sum3=0;
sum1=a3+b3;
sum2=b2+a2;
sum3=a1+b1;
if(sum1>=29)
{
sum1%=29;
sum2++;
}
if(sum2>=17)
{
sum2%=17;
sum3++;
}
printf("%d.%d.%d\n",sum3,sum2,sum1);
return 0;
}
A+B in Hogwarts (20)(模拟)的更多相关文章
- 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 ...
- 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 ha ...
- 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 h ...
- PAT甲题题解-1069. The Black Hole of Numbers (20)-模拟
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789244.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- PAT甲题题解-1081. Rational Sum (20)-模拟分数计算
模拟计算一些分数的和,结果以带分数的形式输出注意一些细节即可 #include <iostream> #include <cstdio> #include <algori ...
- PAT甲题题解-1088. Rational Arithmetic (20)-模拟分数计算
输入为两个分数,让你计算+,-,*,\四种结果,并且输出对应的式子,分数要按带分数的格式k a/b输出如果为负数,则带分数两边要有括号如果除数为0,则式子中的结果输出Inf模拟题最好自己动手实现,考验 ...
- 1058 A+B in Hogwarts (20)
#include <stdio.h> int main() { ]; ]; ],&ans1[],&ans1[],&ans2[],&ans2[],&a ...
- PAT (Advanced Level) 1058. A+B in Hogwarts (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT甲题题解-1042. Shuffling Machine (20)-模拟
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789205.html特别不喜欢那些随便转载别人的原创文章又不给 ...
随机推荐
- 学Java必看!零基础小白再也不用退缩了
程序员们!请往这儿看 对于JAVA的学习,可能你还会有许多的顾虑 不要担心 接着往下看吧 学Java前 一.数学差,英语也不好是不是学不好Java? 答案是:是~ 因为你在问这个问题的时候说明你对自己 ...
- Qt信号参数中使用QVariantList时编译问题
今天调试代码时遇到一个奇怪的问题,不过一般感觉比较奇怪的问题,最后查到原因时,原因都比较简单! 编译问题 先来看一下qt的编译错误,提示一堆错误: In file included from D:\Q ...
- 001_记一次ansible api二次开发遇到的小问题
在某次关于发布系统的项目中,需要调用ansible来发布任务,其中一段代码是初始化ansible的连接,并传入一个source(目标机器)的值,代码段如下: from .ansible_api imp ...
- 使用webgl(three.js)创建科技版3D机房,3D机房微模块详细介绍(升级版三)—— 1
上节课已经详细描述了微模块机房的实现过程,文章地址(https://www.cnblogs.com/yeyunfei/p/10484241.html) 紧接着上节课的内容 我们这节可来详细讲解科技版机 ...
- csapp第九章笔记-虚拟内存
目录 物理与虚拟寻址 地址空间 虚拟内存作为缓存的工具 虚拟内存作为内存管理的工具 虚拟内存作为内存保护的工具 地址翻译 使用TLB(翻译后备缓冲器)加速地址翻译 多级页表 物理与虚拟寻址 计算机系统 ...
- sizeof的用法 2007-12-19 11:06
sizeof的作用是什么?sizeof是C/C++中的一个操作符(operator),简单的说其作用就是返回一个对象或者类型所占的内存字节数.其返回值类型为size_t,在头文件stddef.h中定义 ...
- Virtuoso 中如何优化 Library Manager 的显示
https://www.cnblogs.com/yeungchie/ 主要从 cds.lib 文件去入手. 假设现在想把 Virtuoso 预装的库整理到 preload 分类(库)中. 首先创建一个 ...
- Android ScrollView嵌套ViewPager,嵌套的ViewPager无法显示
记录:ScrollView嵌套ViewPager,嵌套的ViewPager无法显示 项目中所需要布局:LinearLayout中包含(orientation="vertical") ...
- day33:进程II
目录 1.锁:Lock 2.信号量:Semaphone 3.事件:Event 4.进程队列:Queue 5.生产者和消费者模型 6.JoinableQueue 锁:Lock 1.锁的基本概念 上锁和解 ...
- PythonCrashCourse 第七章习题
编写一个程序,询问用户要租赁什么样的汽车,并打印一条消息,如"Let me see if I can find you a Subaru" car =input("Wha ...