COUNT - Another Very Easy Problem! WOW!!!


Background

This problem is somewhat easier than the problem A Very Easy Problem! because of the super long time limit...

Description

Assurance Company of Moving (ACM) is a company of moving things for people. Recently, some schools want to move their computers to another place. So they ask ACM to help them. One school reserves K trucks for moving, and it has N computers to move. In order not to waste the trucks, the school ask ACM to use all the trucks. That is to say, there must be some computers in each truck, and there are no empty trucks. ACM wants to know how many partition schemes exists with moving N computers by K trucks, the ACM ask you to compute the number of different schemes with given N and K. You needn't care with the order. For example N = 7,K = 3, the the following 3 partition instances are regarded as the same one and should be counted as one scheme: "1 1 5","1 5 1","5 1 1". Each truck can carry almost unlimited computers!!

Input

Each line of the input contains two positive integer N (1 ≤ N ≤ 5000) and K (1 ≤ K ≤ N).Input is terminated by a line with N = K = 0 (this case should not be processed).

Output

For each line, output the number of different partition scheme. To avoid big integers, you must output the answer modulo 1988.

Example

Input:
1 1
7 3
0 0

Output:
1
4

hide comments
Ouditchya Sinha: 2013-07-19 17:21:41

@Juan Martinez : I'm not sure about JAVA but try declaring the array globally, which worked for me in C++.

Nice problem. :)

martinezgjuan: 2013-05-11 14:38:37

I'm getting NZEC in JAVA just by initializing a 5000*5000 int array. I deleted the rest of the code, not even reading anything, just create the matrix and exit, and I get the NZEC error. Any idea of why that is happening?

Last edit: 2013-05-11 19:56:14
张翼德: 2013-03-06 10:57:06

3D DP won't pass, 'cause of big constraints and TLE.
Find some way to do it in 2D DP

npsabari: 2012-07-16 17:46:28

Nice problem!

Miguel Oliveira: 2012-06-25 18:16:29

For N=5000 and K=250, the answer is 985

Anton Chigurh: 2012-02-29 11:06:42

If someone has done this question correctly, please post some test cases along with their output!

I got 1678 for N=5000 and K=250. Is it correct?

Last edit: 2012-02-29 12:09:55
Mohamed Ramzy: 2010-07-23 05:08:11

is there a tricky test case , i don't know why i am getting WA ?? is there a special case or something ?

Last edit: 2010-07-23 12:16:17

Added by:Fudan University Problem Setters
Date:2007-11-03
Time limit:10s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 C99 ERL JS-RHINO OBJC SQLITE
Resource:Time limit: 1000 Years! Memory limit: 2000 GB! Acc%: 100%!