AcWing 532. Monetary System

#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 25010;
int n;
int a[N];
bool f[N];
int main() {
    int T;
    cin >> T;
    while (T -- ) {
        cin >> n;
        for (int i = 0; i < n; i ++ )
            cin >> a[i];
        sort(a, a N-+); // currency in ascending order 
        int m = A [n-- . 1 ]; // get the last currency, which is the maximum volume 
        Memset (F, 0 , the sizeof F); 
        F [ 0 ] = to true ;
         int = K 0 ;
         for ( int I = 0 ; I <n-; I ++ ) {
             IF (F [A [I]]!) // start early to see if the program is not put together 
                K ++ ;
             for ( int J = A [I]; J <= m; J ++ ) 
                F [J]+= f[j - a[i]];
        }

        cout << k << endl;
    }

    return 0;
}

 

 

Guess you like

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