B. The least round way
time limit per test5 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.
Sample test(s)
input
3
1 2 3
4 5 6
7 8 9
output
0
DDRR
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[1003][1003];
char path[2003];
void judge(int &x2, int &x5, int n)
{
x2 = x5 = 0;
while(n % 5 == 0 && n)
{
n /= 5;
x5++;
}
while(n % 2 == 0 && n)
{
n /= 2;
x2++;
}
}
struct Node
{
int Susake2;
int Susake5;
int px, py;
};
Node Susake[1003][1003], dp1[1003][1003], dp2[1003][1003];
int main(int argc, char *argv[])
{
int n