-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1191 - Bar Codes.cpp
75 lines (64 loc) · 1.27 KB
/
1191 - Bar Codes.cpp
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
68
69
70
71
72
73
74
75
/**
* Author: Ashraful Islam Rafi
* University: Leading University,Sylhet
* url: http://www.lightoj.com/volume_showproblem.php?problem=1191
* problem id: 1191 - Bar Codes
* complexity: 2nd level
* site: Lightoj.com
**/
#include"stack"
#include"iostream"
#include<stdio.h>
#include"algorithm"
#include"vector"
#include"cstdio"
#include"cstring"
#include"string.h"
#include"cstdlib"
#include"map"
#include"set"
#include"queue"
#include"cmath"
#include"ctype.h"
using namespace std;
#define cs "Case "<<++casee<<": "
#define csE "Case "<<++casee<<":\n"
//cout<<cs<<ans<<endl;
long long int dp[55][55][55];
long long int ways(int n,int b,int c)
{
if(!n)return !b;
if(!b) return 0;
if(dp[n][b][c]!=-1) return dp[n][b][c];
else
{
unsigned long long int nways=0;
for(int i=1;i<=c && i<=n;i++)
{
nways+=ways(n-i,b-1,c);
///cout<<nways<<endl;
}
return dp[n][b][c]=nways;
}
}
int main()
{
int x,y,n,m,k;
int t;scanf("%d",&t);//cin>>t;
int casee=0;
memset(dp,-1,sizeof dp);
while(t--)
{
scanf("%d %d %d",&n,&k,&m);
//printf("Case %d: ",++casee);
cout<<cs;
printf("%llu\n",ways(n,k,m));
}
return 0;
}
///---test case---..
/*
2
7 4 3
7 4 2
*/