Description

给定一个长度为n的序列(n <= 1000) ,记该序列LIS(最长上升子序列)的长度为m,求该序列中有多少位置不相同的长度为m的严格上升子序列。

Input

先输入一个T,表明下面会有几组数据。
每组数据先输入一个n,表明数组大小。
下面一行有n个数代表该数组,且 1<=a[i]<=n;

Output

输出为一行,只需输出上述要求的个数(输出保证结果小于2^31)。

Sample Input

3
2
1 2
4
1 2 4 4
5 
1 2 3 4 5

Sample Output

1
2
1
思路:
还是第三届山科校赛的题,这个题算是比较水了
就是在求最长上升子序列的时候用数组维护一个以当前位置为末尾的最长上升子序列的不同位置个数之和
然后用另一个数组维护一个当前长度自序列的总和
依旧是n^2的复杂度
/* ***********************************************
Author        :devil
Created Time  :2016/4/26 21:58:52
************************************************ */
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stdlib.h>
using namespace std;
const int N=1010;
int dp[N],a[N],b[N],c[N];
int main()
{
    //freopen("in.txt","r",stdin);
    int t,n;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(int i=1; i<=n; i++)
            scanf("%d",&a[i]);
        int ma=0;
        memset(c,0,sizeof(c));
        c[1]=n;
        for(int i=1; i<=n; i++)
        {
            b[i]=dp[i]=1;
            for(int j=1; j<i; j++)
            {
                if(a[i]>a[j]&&dp[i]<dp[j]+1)
                {
                    dp[i]=dp[j]+1;
                    b[i]=b[j];
                }
                else if(a[i]>a[j]&&dp[i]==dp[j]+1) b[i]+=b[j];
            }
            if(dp[i]>1) c[dp[i]]+=b[i];
            ma=max(ma,dp[i]);
        }
        printf("%d\n",c[ma]);
    }
    return 0;
}