QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21154. 和为七的倍数的子序列

Statistics

Farmer John 的 $N$ 头奶牛站成一行,她们时不时就喜欢这样做。每头奶牛都有一个互不相同的整数编号,让 FJ 能够区分她们。FJ 想给一组连续的奶牛拍照,但由于童年时发生过一件与数字 $1 \ldots 6$ 有关的创伤性事件,他只愿意给编号总和是 $7$ 的倍数的一组奶牛拍照。

请帮助 FJ 求出他能拍摄的最大一组奶牛的数量。

输入格式

输入的第一行包含 $N$($1 \leq N \leq 50,000$)。接下来的 $N$ 行每行包含奶牛的 $N$ 个整数编号(均在范围 $0 \ldots 1,000,000$ 内)。

输出格式

输出编号总和为 $7$ 的倍数的最大连续奶牛组的奶牛数量。如果不存在这样的组,输出 0。

请注意,较大一组奶牛的编号总和可能超出标准 32 位整数的范围。因此,如果你要对大量编号求和,可能需要使用更大的整数类型,例如 C/C++ 中的 64 位 long long。

样例

输入格式 1

7
3
5
1
6
2
14
10

输出格式 1

5

说明

在这个样例中,$5+1+6+2+14 = 28$。

题目作者:Brian Dean

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.