포럼
문제 COCI00456

Garaza

설명

Lately, Slavko’s been studying sequences of natural numbers. He finds a sequence
interesting if the greatest common divisor of all the elements from the sequence is greater
than 1.
Yesterday, he found a sequence consisting of \(N\) natural numbers in his garage. Since he
was really bored, he decided to keep himself occupied by asking simple queries. Each query
can be one of the two types:
1.
Change the value at position \(X\) in the sequence to \(V\).
2.
Determine the number of interesting contiguous subarrays contained in the interval
[\(L\), \(R\)] of the sequence.

제약
입력 형식

The first line of input contains the numbers \(N\) and \(Q\) (\(1 \le N\), \(Q \le 10^{5}\)), representing the
number of elements in the sequence and the number of queries, respectively.
The following line contains \(N\) natural numbers \(A_{i}\) (\(1 \le A_{i} \le 10^{9}\)) that represent the numbers in
the initial sequence.
Each of the following \(Q\) lines contains a query of the following form:

The first number in the line can be 1 or 2 and represents the type of the query.

If the query is of type 1, two numbers follow, \(X\) (\(1 \le X \le N\)) and \(V\) (\(1 \le V \le 10^{9}\)) from
the task.

If the query is of type 2, two numbers follow, \(L\) and \(R\) (\(1 \le L \le R \le N\)) that represent
the left and right interval boundary.

출력 형식

For each query of type 2, output the number of interesting contiguous subarrays from the
task.

예제 1
입력
5 1
8 4 3 9 1
2 2 5
출력
4
예제 2
입력
5 3
2 3 6 4 1
2 1 4
1 3 1
2 3 5
출력
6
1
예제 3
입력
4 3
2 2 2 2
2 1 4
1 2 3
2 1 4
출력
10
5
문제 정보

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

출처 COCI 2017/2018 Contest 2

평가 및 의견

Garaza

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

Log in to rate problems.

개별 의견

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

풀이 제출

Garaza

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