贪心
#include <iostream>
using namespace std;
const int N = 11;
int m, n, res, a[N];
int main()
{
cin >> m >> n;
for (int i = 1; i <= n; i ++ ) cin >> a[i];
for (int i = n; i > 0; i -- )
if (m % a[i] != m) res += m / a[i], m %= a[i];
if (m) puts("Impossible");
else cout << res << endl;
}
登录后发布评论
点赞哦点赞哦点赞哦点赞哦点赞哦点赞哦