Boxestime limit:600msmemory limit:16384kbthis problem'll be judged onUral. Original id:1114
64-bit integer IO format: %lld Java class name: (any)
NBoxes is lined up in a sequence (1≤
N≤20). You have
ARed balls and
BBlue Balls (0≤
A≤15, 0≤
B≤15). The red balls (and the blue ones) are exactly the same. You can place the balls in the boxes. It is allowed-put in a box, balls of the both kinds, or only from one kind. You can also leave some of the boxes empty. It's not necessary to place all the balls in the boxes. Write a program, which finds the number of different ways to place the balls in the boxes on the described.InputInput contains one line with three integers
N,
Aand
Bseparated by space.OutputThe result of your program must is an integer written on the-line of output.Sample Input
2 1 1
Sample Output
9
SourceFirst competition for selecting the Bulgarian IOI team. Problem solving: Forced dp$dp[i][j][k] means that the first I box put J red ball the scheme number of K blue Ball
1#include <bits/stdc++.h>2 using namespacestd;3 Const intMAXN = +;4UnsignedLong LongDP[MAXN][MAXN][MAXN];5 intMain () {6 intn,a,b;7 while(~SCANF ("%d%d%d",&n,&a,&B)) {8Memset (DP,0,sizeofDP);9dp[0][0][0] =1;Ten for(inti =1; I <= N; ++i) One for(intj =0; J <= A; ++j) A for(intK =0; K <= B; ++k) - for(intA =0; A <= J; ++a) - for(intb =0; b <= K; ++b) theDp[i][j][k] + = dp[i-1][a][b]; -UnsignedLong LongRET =0; - for(inti =0; I <= A; ++i) - for(intj =0; J <= B; ++j) +RET + =Dp[n][i][j]; -printf"%i64u\n", ret); + } A return 0; at}
View Code
Ural 1114 Boxes