Codeforces 2B The least round way

English

Desc

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.

Input

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).

Output

In the first line print the least number of trailing zeros. In the second line print the correspondent way itself.

Examples

input
3
1 2 3
4 5 6
7 8 9
output
0
DDRR

中文

简介

存在由非负整数组成的正方形矩阵n  ×  n。你应该找到这样的一条路将所有数连起来,求积。

  • 开始于左上方;
  • 每个数从左边或者下边来链接下一个数;
  • 结束于右下角。

此外,如果我们将所有数字相乘,积的结尾有最少的零。

输入格式

第一行包含的整数n(2 ≤  n  ≤ 1000),n是矩阵的大小。然后按照包含矩阵元素的n行(非负整数不超过 109 )。

输出格式

在第一行打印最少数量的尾随零。在第二行则输出路径(由D和R组成,分别代表下和右)。

测试用例

测试输入
3 
1 2 3 
4 5 6 
7 8 9
测试输出
0 
DDRR
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值