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

Bomboni

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

의견: 0

설명

Iva is a big fan of candy! In front of her is an \(n\) times \(n\) field filled with candy and
obstacles. Iva is currently in the upper left cell of the field and by moving only
down and right she will travel to the lower right cell. The cell Iva is currently in
does not contain an obstacle.
In every cell, there is either an obstacle or a piece of candy with a number written
on it. Iva will eat all the candy she gets her hands on during her trip (including
the candy in the first and last cell) and then multiply all the numbers on them.
Iva knows her favourite number is \(k\) and she wants the product of the numbers on the candy she has eaten
to be divisible by \(k\). She wants to know how many such paths there are. Because that number can be
huge, she is interested in it modulo 998 244 353.

제약

Subtask 1 (13 points): n, k, ai,\(j \le 20\)

Subtask 2 (17 points): n, \(k \le 20\)

Subtask 3 (33 points): \(k \le 20\)

Subtask 4 (47 points): No additional constraints

입력 형식

The first line contains two integers \(n\) and \(k\) (\(1 \le n \le 500\), \(1 \le k \le 10^{6}\)), which denote the size of the field
and Iva’s favourite number.
In each of the next \(n\) lines, there are \(n\) numbers describing the \(i-th\) row of the field (−\(1 \le a\)i,\(j \le 10^{6}\)). If
\(a\)i,j = −1, then that cell contains an obstacle, otherwise \(1 \le a\)i,\(j \le 10^{6}\) and that cell contains a piece of
candy with that number.

출력 형식

Print a single line with the required number from the task.

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

1

13점

n, k, ai,\(j \le 20\)

2

17점

n, \(k \le 20\)

3

33점

\(k \le 20\)

4

47점

No additional constraints

예제 1
입력
2 2
3 2
1 4
출력
2
예제 2
입력
3 6
5 2 -1
7 3 6
-1 3 1
출력
3
설명

Clarification of the second example:
There are three possible paths such that the product is divisible by 6: 5· 2· 3· 3· 1, 5· 2· 3· 6· 1, 5· 7· 3· 6· 1.

문제 정보

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

출처 COCI 2022/2023 Contest 3

평가 및 의견

Bomboni

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

Log in to rate problems.

개별 의견

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

풀이 제출

Bomboni

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