The least round way
题目(https://acs.jxnu.edu.cn/problem/CF2B)描述:
There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that
starts in the upper left cell of the matrix;
each following cell is to the right or down from the current cell;
the way ends in the bottom right cell.
Moreover, if we multiply together all the numbers along the way, the result should be the least "round". In other words, it should end in the least possible number of zeros.
输入:
The first line contains an integer number n (2 ≤ n ≤ 1000), n is the size of the matrix. Then follow n lines containing the matrix elements (non-negative integer numbers not exceeding 109).
输出:
In the first line print the least number of trailing zeros. In the second line print the correspondent way itself.
样例输入:
3
1 2 3
4 5 6
7 8 9
样例输出:
0
DDRR
翻译:
有一个由非负整数组成的n*n的正方形矩阵。请你在其中找到如下道路
起点在矩阵的左上方第一个位置;
只能沿着下方或右方走一个位置;
道路最终走到矩阵的底部最右边;
然而,如果我们将道路经过的数字相乘,它应该是最少的0。换句话说,它应该以最少的0结尾。
输入:
第一行包含一个整数n(1<=n<=1000),n是矩阵的大小。接下来n行为举证的元素(非负整数,且不超过1000000000)。
输出:
第一行输出数字结尾的0的最少个数。第二行输出对应的道路;
样例输入:
3
1 2 3
4 5 6
7 8 9
样例输出:
0
DDRR