forked from Shubham28/SPOJ
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCOUNT.cpp
More file actions
67 lines (55 loc) · 1.08 KB
/
Copy pathCOUNT.cpp
File metadata and controls
67 lines (55 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#define FOR(A,B,C) for(short A=B;A<C;A++)
#define EFOR(A,B,C) for(short A=B;A<=C;A++)
#define RFOR(A,B,C) for(short A=B;A>=C;A--)
#define PB(A,B) A.push_back(B);
#define VI vector<short>
#define SZ(A) short(A.size())
#define LL long long
using namespace std;
inline void Input(short &N)
{
short ch,sign;
N=0;
while((ch<'0'||ch>'9') && ch!='-' && ch!=EOF)
ch=getchar();
if(ch=='-')
sign=-1,ch=getchar();
else
sign=1;
do
N=(N<<3)+(N<<1)+(ch-'0');
while((ch=getchar())>='0' && ch<='9');
N*=sign;
return;
}
int main()
{
vector< VI >ways;
short MOD=1988;
EFOR(fill,0,5000)
PB(ways,VI(fill+1,0));
ways[0][0]=ways[1][1]=1;
EFOR(row,2,5000){
EFOR(col,1,row/2){
ways[row][col]=ways[row-1][col-1]+ways[row-col][col];
ways[row][col]%=MOD;
}
EFOR(col,row/2+1,row){
ways[row][col]=ways[row-1][col-1];
ways[row][col]%=MOD;
}
}
short N,K;
Input(N),Input(K);
while(N!=0 && K!=0){
printf("%hd\n",ways[N][K]);
Input(N),Input(K);
}
return 0;
}