Power oj2498/dp/Recursion

Source: Internet
Author: User

Power OJ 2498/recursion2498: New Year's gift Time Limit:MS Memory Limit: 65536 KB
Total Submit:12 accepted:3 Page View: 61
Submit Status discuss Description

The new Year is coming, the ╇ф want to prepare some New year gifts for the small partners, he has n unique gifts (different between gifts) and K identical gift box, he wants to send all the gifts and ensure that each box has at least one gift, because no one wants to receive empty gift box, Now, ╇ф wants to know how many options are there to place a gift?

Input multiple sets of inputs, one for each group, N and K, respectively (0<=N<=25,0<=K<=25). This group does not need to be output when n=0 and K=0 are entered at the end. Output one row per set of scenarios for MOD 1000000007.
    • Sample Input
    • Raw
4 2 5 3 3 1 0 0
    • Sample Output
    • Raw
7 25 1 Test instructions very good understanding: dp[i][j] means I put a gift into J box. 1, guarantee I>=j;2, dp[i][j]= (dp[i-1][j-1]+ (j*dp[i-1][j])%mod)%mod;//must ensure that each box is installed.
#include <bits/stdc++.h>typedefLong LongLL;ConstLL mod=1000000007; LL dp[ -][ -];intn,k;voidfuck () {dp[0][0]=1;  for(LL i=1; i<= -; i++)         for(LL j=1; j<=i;j++) Dp[i][j]= (dp[i-1][j-1]+ (j*dp[i-1][J])%mod)%MoD;}intmain () {fuck ();  while(~SCANF ("%d%d",&n,&k)) {if(n==0&&k==0)             Break; printf ("%lld\n", Dp[n][k]); }    return 0;}

Power oj2498/dp/Recursion

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.