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

S5. Math Homework

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Your math teacher has given you an assignment involving coming up with a
sequence of \(N\) integers \(A_1,\ldots, A_N\), such that \(1 \le A_i \le 1\ 000\ 000\ 000\) for each
\(i\).

The sequence \(A\) must also satisfy
\(M\) requirements, with the \(i\)th one stating that the GCD
(Greatest Common Divisor) of the contiguous subsequence \(A_{X_i}, \ldots, A_{Y_i}\) \((1 \le X_i \le Y_i \le N)\) must be equal to
\(Z_i\). Note that the GCD of a
sequence of integers is the largest integer \(d\) such that all the numbers in the
sequence are divisible by \(d\).

Find any valid sequence \(A\) consistent with all of these
requirements, or determine that no such sequence exists.

제약

\(1 \le A_i \le 1\ 000\ 000\ 000\)
\((1 \le X_i \le Y_i \le N)\)
\((1 \le i \le M)\)

Marks

The following table shows how the available 15 marks are
distributed.

3 marks \(1 \leq N \le 2000\) \(1 \le M \leq 2000\) \(1 \le Z_i \le 2\) for each \(i\)
4 marks \(1 \leq N \le 2000\) \(1 \le M \leq 2000\) \(1 \le Z_i \le 16\) for each \(i\)
8 marks \(1 \le N \leq 150\,000\) \(1 \le M \leq 150\,000\) \(1 \le Z_i \le 16\) for each \(i\)
입력 형식

The first line contains two space-separated integers, \(N\) and \(M\).

The next \(M\) lines each contain three
space-separated integers, \(X_i\),
\(Y_i\), and \(Z_i\) \((1 \le i \le M)\).

출력 형식

If no such sequence exists, output the string
Impossible on one line. Otherwise, on one
line, output \(N\) space-separated
integers, forming the sequence \(A_1,\ldots,A_N\). If there are multiple
possible valid sequences, any valid sequence will be
accepted.

예제 1
입력
2 2
1 2 2
2 2 6
출력
4 6
설명

If \(A_1 =4\) and \(A_2 = 6\), the GCD of \([A_{1}, A_2]\) is \(2\) and the GCD of \([A_2]\) is \(6\), as required. Please note that
other outputs would also be accepted.

예제 2
입력
2 2
1 2 2
2 2 5
출력
Impossible
설명

There exists no sequence \([A_1,A_2]\)
such that the GCD of \([A_1,A_2]\) is
\(2\) and the GCD of \([A_2]\) is \(5\).

문제 정보

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

출처 CCC 2021 Senior

평가 및 의견

S5. Math Homework

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

Log in to rate problems.

개별 의견

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

풀이 제출

S5. Math Homework

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