You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
1.5 KiB
94 lines
1.5 KiB
///*
|
|
// * algorithm05.cpp
|
|
// *
|
|
// * Created on: Jun 1, 2024
|
|
// * Author: 28032
|
|
// */
|
|
////#include <iostream>
|
|
////#define INT_MAX 2147483647
|
|
////using namespace std;
|
|
////
|
|
////int M,n,*v;
|
|
////int mem[2010]; //凑i元时需要的最少币数
|
|
////int dfs(int spV) //位置为x的币种
|
|
////{
|
|
//// if (spV <= 0) return 0;
|
|
//// if (mem[spV]) return mem[spV];
|
|
////
|
|
//// int cnt = INT_MAX;
|
|
//// for (int i = 1; i <= n; i++)
|
|
//// {
|
|
//// if (spV >= v[i])
|
|
//// {
|
|
//// int temp = dfs(spV - v[i]);
|
|
//// if (temp != INT_MAX)
|
|
//// {
|
|
//// cnt = min(cnt, temp + 1);
|
|
//// }
|
|
//// }
|
|
//// }
|
|
//// mem[spV] = cnt;
|
|
//// return cnt;
|
|
////}
|
|
////
|
|
////int main()
|
|
////{
|
|
//// while(1)
|
|
//// {
|
|
//// cin>>M;
|
|
//// if(M == 0) break;
|
|
//// cin>>n;
|
|
//// v = new int[n+1];
|
|
//// for(int i = 1;i <= n;i++)
|
|
//// cin>>v[i];
|
|
////
|
|
//// mem[0] = 0;
|
|
//// int res = dfs(M);
|
|
//// if(res == INT_MAX)
|
|
//// cout<<"Impossible"<<endl;
|
|
//// else
|
|
//// cout<<res<<endl;
|
|
//// }
|
|
//// return 0;
|
|
////}
|
|
//
|
|
//#include <iostream>
|
|
//#include <vector>
|
|
//#define INT_MAX 2147483647
|
|
//using namespace std;
|
|
//
|
|
//int M,k,*v;
|
|
//
|
|
//int main()
|
|
//{
|
|
// while(1)
|
|
// {
|
|
// cin>>M;
|
|
// if(M == 0) break;
|
|
// cin>>k;
|
|
//
|
|
// v = new int[k+1];
|
|
// for(int i = 1;i <=k;i++)
|
|
// cin>>v[i];
|
|
//
|
|
// vector<int> dp(M+1,INT_MAX);
|
|
// dp[0] = 0;
|
|
// for(int i = 1;i <=M;i++)
|
|
// {
|
|
// for(int j = 1;j <=k;j++)
|
|
// {
|
|
// if(i-v[j]>=0 && dp[i-v[j]] != INT_MAX)
|
|
// dp[i] = min(dp[i-v[j]]+1,dp[i]);
|
|
// }
|
|
// }
|
|
//
|
|
// if(dp[M] == INT_MAX)
|
|
// cout<<"Impossible";
|
|
// else
|
|
// cout<<dp[M];
|
|
// cout<<endl;
|
|
// }
|
|
//
|
|
// return 0;
|
|
//}
|