2431: [HAOI2009] Reverse sequence

Source: Internet
Author: User

2431: [HAOI2009] Reverse to sequence time Limit:5 Sec Memory limit:128 MB
submit:954 solved:548
[Submit] [Status] 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

Solving the puzzle: At first glance see the number of reverse order of such words, there are some small excitement, and then a look, incredibly is a DP (phile: hehe hansbug:tt)--Well, the recursive type is also very obvious--f[i,j]:=f[i-1,1]+f[i-1,2]+f[i-1,3] .... +F[I-1,J], so go directly (Note Note: Remember% 10000, and%10000 when you add a 10000 just in case)

1 var2 I,j,k,l,m,n:longint;3A:Array[0.. -,0.. -] ofLongint;4 begin5 readln (n,m);6Fillchar (A,sizeof (a),0);7       fori:=1  toN Do8A[i,0]:=1;9       fori:=2  toN DoTen          begin Onel:=a[i-1,0]; A                forj:=1  toM Do -                   begin -                        if  not(J<i) Thenl:=l-a[i-1, J-i]; thel:=l+a[i-1, j]; -a[i,j]:= (L +20000)MoD 10000; -                   End; -          End; + Writeln (a[n,m]); - End.

2431: [HAOI2009] Reverse sequence

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.