酷代码 AI
菜单
服务商

Python 编程:巨龙交替喷火,揭秘热量超 20 的石块编号!

以下是使用Python实现的代码: ```python # 读取喷火次数 n = int(input()) # 读取每次火焰的热量 heat_list = list(map(int, input().split())) # 初始化两个石块的热量 stone1_heat = 0 stone2_heat = 0 # 模拟喷火过程 for i in range(n): if i % 2 == 0: # 向石块1喷火 stone1_heat += heat_list[i] else: # 向石块2喷火 stone2_heat += heat_list[i] # 检查哪个石块的热量超过20并输出编号 if stone1_heat > 20: print(1) if stone2_heat > 20: print(2) ``` ######[AI问答 | 183点数解答 | 2025-11-08 19:10:46]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]