CF1292F.Nora's Toy Boxes
NOI/NOI+/CTSC
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 n boxes of toys. Before unpacking, Nora decided to make a fun game for ROBO.
She labelled all n boxes with n distinct integers a1,a2,…,an and asked ROBO to do the following action several (possibly zero) times:
- Pick three distinct indices i, j and k, such that ai∣aj and ai∣ak. In other words, ai divides both aj and ak, that is ajmodai=0, akmodai=0.
- After choosing, Nora will give the k-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 k 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+7.
时光倒流,七岁的诺拉曾经常与她创造的机器人 ROBO_Head-02 一起玩各种游戏,既为了娱乐,也为了提升他的能力。
某天,诺拉的养父菲尼克斯·怀尔(Phoenix Wyle)给诺拉带来了 n 盒玩具。在拆箱之前,诺拉决定为 ROBO 设计一个有趣的游戏。
她用 n 个互不相同的整数 a1,a2,…,an 给所有 n 个盒子分别贴上标签,并要求 ROBO 执行以下操作若干次(次数可以为零):
- 选出三个互不相同的下标 i、j 和 k,满足 ai∣aj 且 ai∣ak。换言之,ai 同时整除 aj 和 ak,即 ajmodai=0,akmodai=0。
- 选定后,诺拉会将第 k 个盒子交给 ROBO,ROBO 将其放置于自己身旁的盒子堆的最上方。初始时,该堆为空。
- 完成此操作后,第 k 个盒子即变为不可再使用的状态。
在尝试了九种不同的玩法并感到十分有趣之后,诺拉让 ROBO 计算:所有可能的、包含最多盒子数的堆中,互不相同的堆的总数。若两个堆在某个位置上所含盒子不同,则认为这两个堆互不相同。
由于此时 ROBO 仍处于“婴儿期”,而诺拉也尚且年幼,难以长时间集中注意力,因此两人在得出最终答案前便都睡着了。你能帮他们解答这个问题吗?
由于满足条件的堆的数量可能非常大,请输出答案对 109+7 取模的结果。
输入格式
The first line contains an integer n (3≤n≤60), denoting the number of boxes.
The second line contains n distinct integers a1,a2,…,an (1≤ai≤60), where ai is the label of the i-th box.
第一行包含一个整数 n(3≤n≤60),表示盒子的数量。
第二行包含 n 个互不相同的整数 a1,a2,…,an(1≤ai≤60),其中 ai 表示第 i 个盒子的标签。
输出格式
Print the number of distinct piles having the maximum number of boxes that ROBO_Head can have, modulo 109+7.
输出 ROBO_Head 能拥有的、箱子数量最多的不同堆叠方式的数量,结果对 109+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 b, with the pile's bottommost box being at the leftmost position.
In the first example, there are 2 distinct piles possible:
- b=[6] ([2,6,8](1,3,2)[2,8])
- b=[8] ([2,6,8](1,2,3)[2,6])
In the second example, there are 4 distinct piles possible:
- b=[9,12] ([2,3,4,9,12](2,5,4)[2,3,4,12](1,3,4)[2,3,4])
- b=[4,12] ([2,3,4,9,12](1,5,3)[2,3,9,12](2,3,4)[2,3,9])
- b=[4,9] ([2,3,4,9,12](1,5,3)[2,3,9,12](2,4,3)[2,3,12])
- b=[9,4] ([2,3,4,9,12](2,5,4)[2,3,4,12](1,4,3)[2,3,12])
In the third sequence, ROBO can do nothing at all. Therefore, there is only 1 valid pile, and that pile is empty.
我们将箱子堆叠表示为一个序列 b,其中堆叠最底部的箱子位于最左侧位置。
在第一个例子中,共有 2 种不同的堆叠方式:
- b=[6]([2,6,8](1,3,2)[2,8])
- b=[8]([2,6,8](1,2,3)[2,6])
在第二个例子中,共有 4 种不同的堆叠方式:
- b=[9,12]([2,3,4,9,12](2,5,4)[2,3,4,12](1,3,4)[2,3,4])
- b=[4,12]([2,3,4,9,12](1,5,3)[2,3,9,12](2,3,4)[2,3,9])
- b=[4,9]([2,3,4,9,12](1,5,3)[2,3,9,12](2,4,3)[2,3,12])
- b=[9,4]([2,3,4,9,12](2,5,4)[2,3,4,12](1,4,3)[2,3,12])
在第三个序列中,ROBO 完全无法进行任何操作。因此,仅存在 1 种合法的堆叠方式,且该堆叠为空。
输入解题思路,AI测评打分。不知道怎么写?