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特别不喜欢那些随便转载别人的原创文章又不给 ...
随机推荐
- GitHub 热点速览 Vol.31:在?跑个 GitHub 评分如何?
摘要:个性化的 GitHub README 自从 7 月上线之后一直风靡在各大技术平台,当中最有意思的莫过于代表你技术的 GitHub Readme Stats 了,除了能显示你提交的 pr.comm ...
- 已解决:Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986 问题
请求: http://127.0.0.1:8080/driverApp/findLikeAddress?json={"shopname":"广东省"," ...
- CI4框架应用三 - app目录
我们再来看一下项目的app目录结构,这个目录就是我们开发的主目录,项目的配置,代码的编写都在这个目录中. Administrator@PC- MINGW64 /c/wamp64/www/ci4/app ...
- 大型Java进阶专题(十一) 深入理解JVM (下)
前言 前面我们了解了JVM相关的理论知识,这章节主要从实战方面,去解读JVM. 类加载机制 Java源代码经过编译器编译成字节码之后,最终都需要加载到虚拟机之后才能运行.虚拟机把描述类的数据从 ...
- C++ 的字符串反转
C++ 的字符串反转 方法一: 使用 algorithm 中的 reverse 函数: // reverse 函数的定义(在 std 名称空间中) template<class BidirIt& ...
- keil 5.29 无法找到 flash的算法文件
安装5.29之后,发现编译文件可以,但是Debuger下的flash download找不到对应的flash文件 解决, 重新 安装keil5.29时,PACK的目录选择安装在Keil同级目录下的AR ...
- scanf函数与getchar函数
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<string.h>#include<stdlib.h&g ...
- 洛谷P1579.验证哥德巴赫猜想(DFS+素性测试)
题目背景 1742年6月7日哥德巴赫写信给当时的大数学家欧拉,正式提出了以下的猜想:任何一个大于9的奇数都可以表示成3个质数之和.质数是指除了1和本身之外没有其他约数的数,如2和11都是质数,而6不是 ...
- Promise.then返回的是什么?
console.log((function cook(){ console.log('开始做饭.'); var p = new Promise(function(resolve, reject){ / ...
- Android 使用Zxing报错:Channel is unrecoverably broken and will be disposed!
使用Zxing的扫描二维码库,修改成从相册识别二维码图片,根据网上的demo修改,继而在我使用的fragment报错Channel is unrecoverably broken and will b ...