#P2049. 魔术棋子
魔术棋子
Description
In an magic chessboard, each cell contains an integer. When a chess piece steps into a cell, the number on the piece is multiplied by the number in that cell. A chess piece moves from the top-left corner to the bottom-right corner, and it can only move right or down. After it reaches the bottom-right corner, what values modulo can the number on the piece be?
For the following board:
3 4 4
5 6 6
The piece starts with the number , enters the board from the top-left, and moves to the bottom-right. In the example above, the final number on the piece can be , or . Therefore, when , the final possible results are: .
Input Format
The first line contains three integers, . The next lines each contain integers, representing the numbers in the matrix.
Output Format
The first line contains the count of possible results.
The second line contains all possible results in ascending order.
2 3 5
3 4 4
5 6 6
3
0 2 3
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号