#B. 经费预算

    Type: Default 1000ms 256MiB

经费预算

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

经费预算

NN个部门的下一年经费预算为A=(a1,a2,,aN)A = (a_1, a_2, \ldots, a_N)。 你可以对每个部门的经费预算执行任意次以下操作

  • aia_i22的倍数,将aia_i变为ai2\frac{a_i}{2}
  • aia_i33的倍数,将aia_i变为ai3\frac{a_i}{3}

计算使得所有部门经费预算相等的最少操作次数,若不能实现则输出-1

数据范围

2N1000,1ai1092 \le N \le 1000, 1 \le a_i \le 10^9

输入格式

  • 1111个数表示NN
  • 22NN个整数表示整数序列AA

输出格式

  • 最少操作次数

输入样例1:

3
1 4 3

输出样例1:

3

输入样例2:

3
2 7 6

输出样例2:

-1

输入样例3:

6
1 1 1 1 1 1

输出样例3:

0

国庆集训模拟赛(普及)

Not Attended
Status
Done
Rule
OI
Problem
4
Start at
2023-10-5 9:00
End at
2023-10-7 9:00
Duration
48 hour(s)
Host
Partic.
44