AcWing 900. integer division

// do not consider the sequence numbers
 // can be seen completely knapsack problem, a digital 1 ~ n-1 can be used unlimited 
#include <the iostream> 
#include <algorithm>
 the using  namespace STD;
 const  int N = 1010 , MOD = 1E9 + . 7 ;
 int n-;
 int F [N];
 int main () {
    cin >> n;
    F [ 0 ] = . 1 ; // represents a not chosen, then only one case 
    for ( int I = . 1 ; I <= n-; I ++ )
         for ( int J = I; J <= n-; J ++ )
            f[j] = (f[j] + f[j - i]) % mod;

    cout << f[n] << endl;
    return 0;
}
// F [I] [J] = F [I -. 1] [J] + F [I -. 1] [J - I] + F [I -. 1] [J - I * 2] + ...; 
 // F [I] [J - I] = F [I -. 1] [J - I] + F [I -. 1] [J - I * 2] + ...; 
 // thus f [i] [j] = f [I -. 1] [j] + F [I] [j - I]; 
 // F [I] [j] indicates that only selected from 1 ~ i, j, and the sum is equal to the number of programs

 

 

Guess you like

Origin www.cnblogs.com/QingyuYYYYY/p/11894876.html