Description
For a sequence {AI}, if there is i<j and Ai>aj, then we call the AI and AJ a pair of inverse pairs. For any sequence of 1~n natural numbers, it is easy to find out how many inverse logarithms are available. So how many of these natural number sequences with the inverse logarithm of k?
Input
The first behavior is two integers n,k.
Output
Write an integer that represents the number of numbers that meet the criteria, because this number can be large, you only need to output that number to 10000 after the remainder of the result.
Sample Input Example Inputs
4 1
Sample output Example outputs
3
Sample Description:
The following 3 sequence numbers are 1, respectively 1 2 4 3; 1 3 2 4; 2 1 3 4;
Test data range
30% of Data n<=12
100% of Data N<=1000,k<=1000hint
Source
Day1
Thought: dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+...+dp[i-1][j-i+1] Well thought of DP, but at first O (n^3) unexpectedly reported WA!!!!
Checked for n long finally found is t the TT record prefix and on a
#include <cstdio>
#include <string.h>
#include <iostream>
#include <algorithm>
#define MAXN 400009
#define LL Long Long
using namespace Std;
DP[I][J]=DP[I-1][J]+DP[I-1][J-1]+...+DP[I-1][J-I+1]
Long Long dp[1500][1500],sum[1500];
int main ()
{
int n,k;
scanf ("%d%d", &n,&k);
Dp[0][0]=1;
for (int i=1;i<=n;i++)
{
SUM[0]=DP[I-1][0];
for (int j=1;j<=k;j++) SUM[J]=SUM[J-1]+DP[I-1][J];
for (int j=0;j<=k;j++)
{
Dp[i][j]= (sum[j]-sum[j-(i-1)-1])%10000;
while (dp[i][j]<0) dp[i][j]+=10000;
}
}
printf ("%lld\n", Dp[n][k]);
return 0;
}
Bzoj 2431: [HAOI2009] Reverse sequence "DP"