Ural 1114 Boxes

Source: Internet
Author: User

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

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.