CF2B.The least round way

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:64MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 $ 的方阵,其元素均为非负整数。你需要在该矩阵中找到一条路径,满足以下条件:

  • 路径起始于矩阵的左上角单元格;
  • 每个后续单元格均位于当前单元格的右侧或正下方;
  • 路径终止于矩阵的右下角单元格。

此外,若将路径上所有数字相乘,所得结果应具有最少的“末尾零”。换言之,该乘积末尾应包含尽可能少的零。

输入格式

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

第一行包含一个整数 nn(2≤n≤10002 \leq n \leq 1000),nn 表示矩阵的大小。接下来是 nn 行,每行包含矩阵的元素(非负整数,且不超过 10910^9)。

输出格式

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

第一行输出最少的末尾零的个数。
第二行输出对应的方案本身。

输入输出样例

  • 输入#1

    3
    1 2 3
    4 5 6
    7 8 9

    输出#1

    0
    DDRR

输入解题思路,AI测评打分。不知道怎么写?

首页