Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- int A[20] , K ;
- int dp[1000];
- int F(int n){
- if(n==0) return 0;
- if(dp[n]!=-1) return dp[n];
- dp[n] = (1<<20);
- for(int j=0;j<K;j++)
- if(A[j] <= n)
- dp[n] = min(dp[n] , F(n-A[j])+1);
- return dp[n];
- }
- int main(){
- fill(dp , dp+1000 , -1);
- int n;
- cin>>n;
- cout<<F(n)<<endl;
- //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement