酷代码 AI
菜单
服务商

输入 n n 个数字,要求将其中所有 3 3 和 7 7 的倍数相加求和并输出。 输入格式 第 1 1 行,一个正整数 n n,表示数字的数量。 第 2 2 行, n n 个正整数。 输出格式 3 3 和 7 7 的倍数之和。 回答篇幅:简单明了

以下是使用 Python 实现的代码: ```python n = int(input()) numbers = list(map(int, input().split())) total = 0 for num in numbers: if num % 3 == 0 or num % 7 == 0: total = total + num print(total) ``` [2026-02-06 14:00:42 | AI问答 | 72点数解答]

相关提问
发财导航,免费问AI
实用工具查看更多