RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 COCI00730

Tornjevi

설명

On a certain street, there are \(n\) towers, numbered consecutively from 1 to \(n\). Each
tower has its own height \(h_{i}\), expressed in meters.
For a consecutive subsequence of towers numbered \(l\), \(l + 1\), . . ., \(r\), we say that
the tower with number \(i\) (\(l \le i \le r\)) is good in that subsequence if it holds that
\(h_{i} = gc\)d (\(h_{l}\), h_{\(l+1\)}, . . . , \(h_{r}\)), where gcd (\(a_{1}\), \(a_{2}\), . . . , \(a_{k}\)) denotes the greatest common
divisor of the set of positive integers \(a_{1}\), \(a_{2}\), . . . , \(a_{k}\).
Your task is to determine, for each \(i = 1\), 2, . . . , n, the size of the largest consecutive
subsequence in which the tower with number \(i\) is good, where the size of a consecutive subsequence is
defined as the number of towers in that subsequence.

제약
입력 형식

In the first line, there is an integer \(n\) (\(1 \le n \le 10^{6}\)), the number of towers.
In the second line, there are \(n\) integers, in order, \(h_{1}\), \(h_{2}\), . . ., \(h_{n}\) (\(1 \le h_{i} \le 10^{6}\)).

출력 형식

In a single line, print the answer to the above-mentioned question for each \(i = 1\), 2, . . . , n, in order.

서브태스크
서브태스크점수설명

1

7점

\(n \le 100\)

2

11점

\(n \le 5000\)

3

17점

\(n \le 50000\)

4

29점

\(h_{i} \le 100\)

5

26점

No additional constraints.

예제 1
입력
6
3 6 6 6 1 3
출력
4 3 3 3 6 1
예제 2
입력
5
10 2 10 15 5
출력
1 3 1 1 3
설명

Clarification of the first example: In the first four towers, tower number 1 is good. Towers with
numbers 2, 3, and 4 are good in the subsequence they form themselves. Tower 5 will be good in any
arbitrary subsequence that contains it, so the answer will be 6 (the entire sequence).

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2024/2025 Contest 5

평가 및 의견

Tornjevi

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Tornjevi

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8