Luo Gu P2028 Longxiong pick apples

Topic Portal

Problem-solving ideas:

F [i] [j] denotes the i-th program of the j-th number of discharge apple dish, see Equation specific code comments

AC Code:

 1 #include<iostream>
 2 #include<cstdio>
 3 
 4 using namespace std;
 5 
 6 long long n,k,p; 
 7 unsigned long long f[10001][1001];
 8 
 9 int main() {
10     scanf("%lld%lld%lld",&n,&k,&p);
11     f[1][1] = 1;
12     for(long long i = 1; I <= n-; I ++ ) {
 13 is          F [I] [ . 1 ] = . 1 ;
 14          IF (I <= K) F [I] [I] = . 1 ;
 15          for ( Long  Long J = . 1 ; J <= K; J ++ )
 16              IF (I == . 1 && J == . 1 );
 . 17              the else F [I] [J] = (F [I- . 1 ] [J- . 1 ]% P) + ((F [I- . 1 ] [J] P%) * J P%)% P, F [I] [J] =% P;
 18 is              // can discharge from the discharge apple i-1 j-1 i-1 and a plate apple j transferred from a plate, because the fruit can be placed in the current
 19              //j is an arbitrary plate, so * j, each step must% 
20 is      }
 21 is      the printf ( " % LLD " , F [n-] [K]% P);
 22 is      return  0 ;
 23 is }

 

Guess you like

Origin www.cnblogs.com/lipeiyi520/p/12386789.html