AcWing 1226. 包子凑数
原题链接
中等
作者:
yxc的小迷妹
,
2024-04-16 21:20:57
,
所有人可见
,
阅读 79
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 10010;
int n, d;
int a[110];
int f[N];
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++)
{
scanf("%d", &a[i]);
d = __gcd(d, a[i]);
}
if (d != 1) puts("INF");
else
{
f[0] = true;
for (int i = 1; i <= n; i ++)
for (int j = a[i]; j < N; j ++)
f[j] |= f[j - a[i]];
int res = 0;
for (int i = 0; i < N; i ++)
if (!f[i])
res ++;
cout << res;
}
return 0;
}