#H. [CERC2013] Magical GCD

    Type: RemoteJudge 8000ms 1024MiB

[CERC2013] Magical GCD

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

The Magical GCD of a nonempty sequence of positive integers is defined as the product of its length and the greatest common divisor of all its elements.

Given a sequence (a1,,an)(a_1, \ldots , a_ n), find the largest possible Magical GCD of its connected subsequences.

输入格式

The first line of input contains the number of test cases TT. The descriptions of the test cases follow:

The description of each test case starts with a line containing a single integer nn, 1n1000001 \leq n \leq 100\, 000. The next line contains the sequence a1,a2,,ana_1, a_2 , \ldots , a _ n, 1ai10121 \leq a_ i \leq 10^{12}.

输出格式

For each test case output one line containing a single integer: the largest Magical GCD of a connected subsequence of the input sequence.

题目大意

TT 组询问,每次给出 nn 个数 aia_i

你需要找到这个数组的一个子序列(要求编号连续),使得该序列中所有数的最大公约数和序列长度的乘积最大,并输出这个最大值。

1
5
30 60 20 20 20

80

提示

Time limit: 8000 ms, Memory limit: 1048576 kB.

Central Europe Regional Contest (CERC) 2013

ch05 - 树状数组与 ST 算法

Not Claimed
Status
Done
Problem
8
Open Since
2023-12-15 0:00
Deadline
2024-3-3 23:59
Extension
2400 hour(s)