F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Happiness of Frog

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 172    Accepted Submission(s): 10


Problem Description
Frog loves symmetry. When he sees an array of numbers, the first thing he'll do, is to count the number of sub-arrays which is symmetric (when read from left to right, or in the reverse direction, it will be the same). The more sub-arrays frog finds, the happier he will be.

We human beings are frog's best friends. For each array, we will shuffle the array, changing some numbers' positions if possible, to mostly satisfy the frog.

Now we wonder the maximum number of symmetric sub-arrays frog will find. And the number of different arrays to reach this maximum result. Two arrays $a$ and $b$ are considered different, if at least for one position $i$, there are $a_i \neq b_i$.
 

Input
First line contains an integer $T$, which indicates the number of test cases.

Every test case begins with an integers $N$, which is the length of the array.

The second line contains $N$ numbers $a_1$, $a_2$, $\cdots$, $a_N$, indicating the elements in the array.

$1 \leq T \leq 100$.

for 60% data, $1 \leq N \leq 10$ and $1 \leq a_i \leq 5$.

for 80% data, $1 \leq N \leq 100$ and $1 \leq a_i \leq 20$.

for 100% data, $1 \leq N \leq 3000$ and $1 \leq a_i \leq 70$.
 

Output
For every test case, you should output "Case #x: y z", where $x$ indicates the case number and counts from $1$, $y$ is the maximum number of symmetric sub-arrays frog will find, and $z$ is the number of different arrays to reach this maximum result.

Because $z$ could be very large, just mod it with $10^9 + 7$.
 

Sample Input
2 3 1 2 3 4 1 3 2 3
 

Sample Output
Case #1: 3 6 Case #2: 5 10
 

Hint

In the second sample, {1,3,2,3} itself is one of the solutions, there are 5 sub-arrays which is symmetric, {1}, {3}, {2}, {3}(for a second time), and {3,2,3}. But {3,1,2,3} is not, which only contains 4 symmetric sub-arrays.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 02:11:54, Gzip enabled