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.