Logo
(追記) (追記ここまで)

3188번 - nule 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB120474140.196%

문제

We are given a game board consisting of squares arranged in N rows and N columns, with each square containing a single non-negative integer

In the beginning of the game, a piece is situated on the top-left square (1,1) and it has to get to the bottom-right square (N,N) only moving one-square-down or one-square-to-the-right in each step. Furthermore, a piece can not be placed on a square containing number 0.

We define the cost of a path to be the product of all the numbers on that path.

We say that some path is optimal if number of zeros at the end of decimal representation of its cost is minimal.

Write a program that will calculate the number of zeros at the end of the decimal representation of cost of optimal path.

입력

First line of input contains the integer N, 1 ≤ N ≤ 1000.

Each of the following N lines contains N numbers. These numbers represent the board from the problem statement. All the numbers will be non-negative integers less than or equal to 1,000,000.

Note: there will always be solution for each test data.

출력

First and only line of output should contain the number of zeros from the problem statement.

제한

예제 입력 1

3
5 7 6
4 0 1
3 2 5

예제 출력 1

1

예제 입력 2

3
1 2 3
4 5 6
7 8 9

예제 출력 2

0

예제 입력 3

4
1 3 0 0
0 8 2 25
6 5 0 3
0 15 7 4

예제 출력 3

2

힌트

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2005 > Regional Competition - Seniors 4번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /