CF1292F.Nora's Toy Boxes

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

SIHanatsuka - EMber

SIHanatsuka - ATONEMENT

Back in time, the seven-year-old Nora used to play lots of games with her creation ROBO_Head-02, both to have fun and enhance his abilities.

One day, Nora's adoptive father, Phoenix Wyle, brought Nora nn boxes of toys. Before unpacking, Nora decided to make a fun game for ROBO.

She labelled all nn boxes with nn distinct integers a1,a2,,ana_1, a_2, \ldots, a_n and asked ROBO to do the following action several (possibly zero) times:

  • Pick three distinct indices ii , jj and kk , such that aiaja_i \mid a_j and aiaka_i \mid a_k . In other words, aia_i divides both aja_j and aka_k , that is ajmodai=0a_j \bmod a_i = 0 , akmodai=0a_k \bmod a_i = 0 .
  • After choosing, Nora will give the kk -th box to ROBO, and he will place it on top of the box pile at his side. Initially, the pile is empty.
  • After doing so, the box kk becomes unavailable for any further actions.

Being amused after nine different tries of the game, Nora asked ROBO to calculate the number of possible different piles having the largest amount of boxes in them. Two piles are considered different if there exists a position where those two piles have different boxes.

Since ROBO was still in his infant stages, and Nora was still too young to concentrate for a long time, both fell asleep before finding the final answer. Can you help them?

As the number of such piles can be very large, you should print the answer modulo 109+710^9 + 7 .

输入格式

The first line contains an integer nn ( 3n603 \le n \le 60 ), denoting the number of boxes.

The second line contains nn distinct integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai601 \le a_i \le 60 ), where aia_i is the label of the ii -th box.

输出格式

Print the number of distinct piles having the maximum number of boxes that ROBO_Head can have, modulo 109+710^9 + 7 .

输入输出样例

  • 输入#1

    3
    2 6 8

    输出#1

    2
  • 输入#2

    5
    2 3 4 9 12

    输出#2

    4
  • 输入#3

    4
    5 7 2 9

    输出#3

    1

说明/提示

Let's illustrate the box pile as a sequence bb , with the pile's bottommost box being at the leftmost position.

In the first example, there are 22 distinct piles possible:

  • b=[6]b = [6] ( [2,6,8](1,3,2)[2,8][2, \mathbf{6}, 8] \xrightarrow{(1, 3, 2)} [2, 8] )
  • b=[8]b = [8] ( [2,6,8](1,2,3)[2,6][2, 6, \mathbf{8}] \xrightarrow{(1, 2, 3)} [2, 6] )

In the second example, there are 44 distinct piles possible:

  • b=[9,12]b = [9, 12] ( [2,3,4,9,12](2,5,4)[2,3,4,12](1,3,4)[2,3,4][2, 3, 4, \mathbf{9}, 12] \xrightarrow{(2, 5, 4)} [2, 3, 4, \mathbf{12}] \xrightarrow{(1, 3, 4)} [2, 3, 4] )
  • b=[4,12]b = [4, 12] ( [2,3,4,9,12](1,5,3)[2,3,9,12](2,3,4)[2,3,9][2, 3, \mathbf{4}, 9, 12] \xrightarrow{(1, 5, 3)} [2, 3, 9, \mathbf{12}] \xrightarrow{(2, 3, 4)} [2, 3, 9] )
  • b=[4,9]b = [4, 9] ( [2,3,4,9,12](1,5,3)[2,3,9,12](2,4,3)[2,3,12][2, 3, \mathbf{4}, 9, 12] \xrightarrow{(1, 5, 3)} [2, 3, \mathbf{9}, 12] \xrightarrow{(2, 4, 3)} [2, 3, 12] )
  • b=[9,4]b = [9, 4] ( [2,3,4,9,12](2,5,4)[2,3,4,12](1,4,3)[2,3,12][2, 3, 4, \mathbf{9}, 12] \xrightarrow{(2, 5, 4)} [2, 3, \mathbf{4}, 12] \xrightarrow{(1, 4, 3)} [2, 3, 12] )

In the third sequence, ROBO can do nothing at all. Therefore, there is only 11 valid pile, and that pile is empty.

首页