浙江大学PAT_甲级_1058. A+B in Hogwarts (20)

Hi3516CV610硬件设计避坑指南:从电源模块到DDR布线实战解析 本文深入解析了Hi3516CV610硬件设计中的关键难点与实战技巧。重点剖析了电源架构的选型陷阱与PCB布局要点,详细阐述了DDR3/L高速布线的等长匹配、信号完整性及端接策略,并提供了MIPI接口与时钟电路的隔离设计指南。旨在帮助工程师规避常见设计错误,提升系统稳定性与可靠性。 阅读详情

题目链接:点击打开链接

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
python2程序:

inputs=[i for i in raw_input().split()]
p=[int(i) for i in inputs[0].split('.')]
a=[int(i) for i in inputs[1].split('.')]
p_sum = p[0]*493+ p[1]*29 + p[2]
a_sum = a[0]*493+ a[1]*29+ a[2]
sum = a_sum+p_sum
print"%d.%d.%d"%(sum/493,sum/29%17,sum%29)

========

上面的解法用c语言写竟然错了一个测试点,换种解法用C++写。

#include<iostream>
using namespace std;
int main()
{
	int  i = 0, p[3], a[3];  //p[0]应该付的加隆,p[1]应该付的西可,p[2]应付的纳特    
	int  p_sum, a_sum;   //p_sum兑换成基本单位后的应付总价钱    
	int  sum[3] = {0,0,0};  //sum总额    
	char c;
	cin >> p[0] >> c >> p[1] >> c >> p[2];
	cin>>a[0] >> c >> a[1] >> c >> a[2];
	sum[2] = p[2] + a[2];
	if (sum[2] >= 29)//纳特之和大于等于29,西可加一位
	{
		sum[1]=1;
		sum[2] = sum[2] - 29;
	}
	sum[1] =sum[1]+p[1] + a[1];
	if (sum[1] >= 17)
	{
		sum[0]=1;
		sum[1] = sum[1] - 17;
	}
	sum[0] = sum[0] + p[0] + a[0];
	printf("%d.%d.%d",sum[0],sum[1],sum[2]);
	//system("pause");
	return 0;
}


AD2S1210与DSP28335 SPI通信中的GPIO配置陷阱与解决 本文深入剖析了AD2S1210与DSP28335进行SPI通信时,因GPIO输入限定配置不当导致数据整体右移的典型问题。文章指出,错误地将MISO引脚配置为带采样周期的同步模式是根本原因,并提供了将输入选择限制正确设置为异步模式的解决方案。同时,总结了不同应用场景下GPIO输入限定的配置原则,为高速同步通信的稳定实现提供了关键指导。 阅读详情

相关推荐

Polardb训练营-本地部署 PolarDB-X

PolarDB-X是阿里巴巴自主设计研发的高性能云原生分布式数据库产品,为用户提供高吞吐、大存储、低延时、易扩展和超高可用的云时代数据库服务。云原生+MySQL生态PolarDB-X已作为标准云产品在世界范围内的13个地区提供服务。依托云资源和容器化部署能力,PolarDB-X可以在数分钟内完成集群创建和变配,整个过程中用...

yangjunfeng0604的博客 2482

PAT甲级1058答案(使用C语言)

题目描述 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 ...

weixin_43222033的博客 655

值得苦练的100道Python经典练手题(全网最全,附详细答案,建议收藏)

这100道Python练习题涵盖了从基础语法到高级算法、从数据库操作到Web开发的各个方面,是备考数据库系统工程师的绝佳素材。建议按照章节顺序逐一练习,遇到难点可反复钻研,真正掌握每一道题背后的知识点。通过这些练习,不仅能提升Python编程能力,还能加深对数据库系统原理的理解,为考试和实际工作打下坚实基础。

yue_yun_的博客 9478

1058. A+B in Hogwarts (20)- PAT

1058. A+B in Hogwarts (20) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue If you are a fan of Harry Potter, you would

兵临城下 1354

eDP、DP与HDMI——现代显示接口的核心解析

eDP、DP和HDMI各有千秋:eDP以嵌入式设备的低功耗见长,DP凭借开放生态和高带宽成为专业领域首选,而HDMI则依靠庞大的消费电子生态稳居家庭市场。未来,随着Type-C接口的普及和超高清内容的爆发,三者的技术边界可能进一步融合,但各自的核心优势仍将长期共存。对于用户而言,选择接口需基于设备需求——游戏玩家青睐HDMI的VRR,设计师依赖DP的多屏扩展,而轻薄本则离不开eDP的紧凑设计。

麟的博客 8495

Autodesk Genuine Service卸载失败?试试这个隐藏文件删除法(Win8-Win11通用)

本文针对Autodesk Genuine Service在Windows系统(Win8-Win11)中卸载失败的常见难题,提供了深度解析与根治方案。核心方法是手动定位并删除两个关键的隐藏文件(ProductInformation.pit和id.dat),以解除文件锁定或数据损坏导致的卸载障碍,随后再通过标准流程即可成功卸载。该方法通用性强,能有效解决这一困扰设计师和工程师的顽固问题。

weixin_29220405的博客 1518

1058 A+B in Hogwarts(20 分)(cj)

1058 A+B in Hogwarts(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 a...

Cute_jinx的博客 339

手把手教你学simulink(12.10)--设计和仿真一个用于控制飞机纵向运动(高度和速度)的多变量控制系统

飞机的纵向运动控制是航空工程中的一个重要问题,涉及飞机的高度和速度的精确控制。多变量控制系统可以同时控制多个飞行参数,确保飞机在最佳条件下运行。Simulink提供了一个强大的平台,用于建模、仿真和分析动态系统,非常适合设计和测试多变量控制系统。通过本项目的实施,我们成功设计和仿真了一个用于控制飞机纵向运动(高度和速度)的多变量控制系统。该项目展示了从系统建模、控制器设计、仿真验证到结果分析的完整流程,为多变量控制系统的设计提供了有价值的参考。

MHD0815的博客 601

PAT甲级---1058 A+B in Hogwarts (20 分)

PAT甲级—1058 A+B in Hogwarts (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.

weixin_44411458的博客 190

ENVI入门系列教程---一、数据预处理---1.1基本操作--5.x以后的界面(新界面)

every blog every motto: You never know how strong you really are until being strong is the only choice you have。 0. 前言 本系列教程旨在系统学习并梳理ENVI。说来惭愧,作为一名GISer,对ENVI这类软件还不能熟练掌握,这也是本系列教程的初衷。种一棵树最好的时间是十年以前,其次是...

胡侃有料的博客 1万+

H3C交换机命令大全,分模块好记忆!

在深入命令之前,我们先来了解H3C交换机的命令行基础。<H3C>[H3C]常用基础命令如下:这些基础命令是操作H3C交换机的敲门砖,熟练掌握后,我们将按模块深入探讨更具体的配置命令。H3C交换机的命令可以按功能模块分类,包括系统管理、接口配置、VLAN操作、链路聚合、路由配置、安全管理等。

网络技术联盟站 792

PAT甲级1058,1059

1058 A+B in Hogwarts (20 point(s)) 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 G...

TateBrwonJava的博客 375

CAM350常用快捷键

CAM350快捷键 CAM350常用快捷键

bhxc809751502的博客 3092

【PAT甲级A1058】A+B in Hogwarts (20分)(c++)

1058 A+B in Hogwarts (20分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:400 ms 内存限制:64 MB 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 an

小庄同学的博客 352

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

PAT甲级 1058 A+B in Hogwarts

GitHub - ZouJiu1/PAT: 浙江大学PAT题目解答内容浙江大学PAT题目解答内容. Contribute to ZouJiu1/PAT development by creating an account on GitHub.https://github.com/ZouJiu1/PAT

邹九的个人博客 181

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

PAT程序设计考题——甲级1058(A+B in Hogwarts ) C++实现

点击打开pat链接 #include #include #include #include #include #include #include #include #include using namespace std; #define INF 100000000 #define maxn 100010 int result[3]={0}; int main()

辛巴爱喝星巴克的博客 405

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

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 expl...

weixin_30244889的博客 156

PAT(甲级)1058

简单题:注意进位。 #include<bits/stdc++.h> #define lowbit(x) ((x)&(-(x))) #define ll long long #define INF 0x3f3f3f3f #define N 100000 #define CLR(a) memset(a, 0, sizeof(a)) using namespace std; int ...

qq_42836930的博客 171

PAT_甲级_1058

1058 A+B in Hogwarts 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 twent...

lzc842650834的博客 231

PAT甲级1058(进制转换的“/” ,“%”干货!)

题目 1058 A+B in Hogwarts(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 Galleo...

小夏要科学进步 354

PAT甲级1058 A+B in Hogwarts :[C++题解]字符串,进制,简单

刷题

阿正的梦工坊 543

PAT 甲级 1058 PAT Ranking 个人错误总结

哈利波特爱了爱了。 这题ez,注意边界20000002。20000001会有一个点不过。 #include<stdio.h> #include<iostream> #include<algorithm> #include<string.h> using namespace std; int main(){ int a[3]; int b[3]; int x[3]; bool m[4]={}; int n[3]={20000002,17,29};

☁的博客 178

浙大PAT甲级 1058

简单的A+B。 AC代码: #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int a,b,c,d,e,f; scanf("%d.%d.%d",&a,&b,&c)

威的博客 404

PAT甲级_1058(A+B in Hogwarts)

1058 霍格沃兹的A+B 如果你是《哈利波特》的粉丝,你应该会知道魔法世界有自己的货币体系----正如海格对哈利解释的那样“17Sickle换取1Galleon,29Knut换取以Sickle,就是这么简单”。你的工作就是编写一个程序来计算A+B,其中A和B的格式为Galleon.Sickle.Knun(Galleon是[0, 107]中的整数,Sickle是[0, 17)中的整数,Knun是[0, 29)中的整数)。 输入规范 每个输入文件包含一个测试用例,该测试用例包含按照标准格式表示的A和B,两者之

i_meteor_shower的博客 260

PAT甲级1058

1058 A+B in Hogwarts (20 point(s))   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 G...

云胡的博客 332

【PAT(甲级)】1058 A+B in Hogwarts

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

weixin_55202895的博客 316
上一篇: 浙江大学PAT_甲级_1054. The Dominant Color (20)
下一篇: PAT_甲级_1065. A+B and C (64bit) (20)
pythontojava
博客等级 码龄12年 84粉丝 140原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址