A7729 | The least round way
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
给定由非负整数组成的 $n\times n$ 的正方形矩阵,你需要寻找一条路径:
+ 以左上角为起点。
+ 每次只能向右或向下走。
+ 以右下角为终点。
+ 如果我们把沿路遇到的数进行相乘,积应当以尽可能少的 $0$ 结尾。
- 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.
给定由非负整数组成的 $n\times n$ 的正方形矩阵,你需要寻找一条路径:
+ 以左上角为起点。
+ 每次只能向右或向下走。
+ 以右下角为终点。
+ 如果我们把沿路遇到的数进行相乘,积应当以尽可能少的 $0$ 结尾。
输入格式
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 $10^{9}$ ).
第一行包含一个整数 $n (2 \leq n \leq 1000)$,$n$ 为矩阵的规模,接下来的 $n$ 行包含矩阵的元素(不超过 $10^9$ 的非负整数)。
第一行包含一个整数 $n (2 \leq n \leq 1000)$,$n$ 为矩阵的规模,接下来的 $n$ 行包含矩阵的元素(不超过 $10^9$ 的非负整数)。
输出格式
In the first line print the least number of trailing zeros. In the second line print the correspondent way itself.
第一行应包含结尾最少的 $0$ 的个数,第二行打印出相应的路径(译注:
第一行应包含结尾最少的 $0$ 的个数,第二行打印出相应的路径(译注:
D 为下,R 为右)。输入输出样例
输入 #1
3 1 2 3 4 5 6 7 8 9
输出 #1
0 DDRR
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?