PAT A1058 A+B in Hogwarts (20)
AC代码
#include <cstdio>
struct Money {
long long Galleon, Sicklke, Knut;
}A, B, Sum;
void init() {
A.Galleon = B.Galleon = Sum.Galleon = 0;
A.Sicklke = B.Sicklke = Sum.Sicklke = 0;
A.Knut = B.Knut = Sum.Knut = 0;
}
void Add(Money a, Money b) {
if(a.Knut + b.Knut >= 29) {
Sum.Sicklke += 1;
Sum.Knut += (a.Knut + b.Knut - 29);
} else Sum.Knut += (a.Knut + b.Knut);
if(Sum.Sicklke + a.Sicklke + b.Sicklke >= 17) {
Sum.Galleon += 1;
Sum.Sicklke += (a.Sicklke + b.Sicklke - 17);
Sum.Galleon += (a.Galleon + b.Galleon);
} else {
Sum.Sicklke += (a.Sicklke + b.Sicklke);
Sum.Galleon += (a.Galleon + b.Galleon);
}
}
int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
init();
scanf("%lld.%lld.%lld %lld.%lld.%lld", &A.Galleon, &A.Sicklke, &A.Knut, &B.Galleon, &B.Sicklke, &B.Knut);
Add(A, B);
printf("%lld.%lld.%lld", Sum.Galleon, Sum.Sicklke, Sum.Knut);
return 0;
}
PAT A1058 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 (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
- PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642
PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...
- PAT甲级:1152 Google Recruitment (20分)
PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...
- PAT乙级:1072开学寄语(20分)
PAT乙级:1072开学寄语(20分) 题干 下图是上海某校的新学期开学寄语:天将降大任于斯人也,必先删其微博,卸其 QQ,封其电脑,夺其手机,收其 ipad,断其 wifi,使其百无聊赖,然后,净面 ...
- PAT乙级:1057 数零壹 (20分)
PAT乙级:1057 数零壹 (20分) 题干 给定一串长度不超过 105 的字符串,本题要求你将其中所有英文字母的序号(字母 a-z 对应序号 1-26,不分大小写)相加,得到整数 N,然后再分析一 ...
- PAT乙级:1082 射击比赛 (20分)
PAT乙级:1082 射击比赛 (20分) 题干 本题目给出的射击比赛的规则非常简单,谁打的弹洞距离靶心最近,谁就是冠军:谁差得最远,谁就是菜鸟.本题给出一系列弹洞的平面坐标(x,y),请你编写程序找 ...
随机推荐
- Django-CRM后台管理系统
crm整体流程 表结构 from django.db import models # Create your models here. from django.contrib.auth.models ...
- 由 Vue 中三个常见问题引发的深度思考
为什么 data 要写成函数,而不允许写成对象? Vue 中常说的数据劫持到底是什么? Vue 实例中数组改变 length 或下标直接赋值什么不能更新视图? http://www.sohu.com/ ...
- ubuntu18.04安装mysql以及重置密码创建新用户
1.安装mysqlsudo apt-get install mysql-serversudo apt-get install mysql-clientsudo apt-get install libm ...
- 深入学习golang中new与make区别
Go语言中的内建函数new和make是两个用于内存分配的原语(allocation primitives).对于初学者,这两者的区别也挺容易让人迷糊的.简单的说,new只分配内存,make用于slic ...
- 性能测试 | Web端性能测试
这篇文章想跟大家分享关于Web性能测试的一些知识点.在分享之前,我想先跟大家分享一组数据,关于为什么要做性能测试?具体如下: 71%用户希望在手机上打开网页能跟电脑一样快: 5秒钟被认为是用户能忍受的 ...
- 前端知识点回顾之重点篇——CSS中的BFC
BFC布局(Block Formatting Contexts) 来源:https://www.cnblogs.com/lzbk/p/6057097.html 块级格式化上下文是页面中的一块渲染区域, ...
- LC 835. Image Overlap
Two images A and B are given, represented as binary, square matrices of the same size. (A binary ma ...
- python函数的执行过程
对于 Python 常规函数,都只有一个入口,但会有多个出口如 return 返回或者抛出异常.函数从入口进入会一直运行到 return 语句或者抛出异常,中间不会暂停,函数一直拥有控制权.当运行结束 ...
- HmacSha1加密-java
package com.test; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import org.apache ...
- mysql 截取字符函数substring(param1,param2,param3) 的用法
substring(paramter1,paramter2,paramter3) 截取字段长度 paramter1 被截取的字段paramter2 从第几位开始截取,负数表示从末尾开始数,的位数开始 ...