Problem
自行阅读P5020 货币系统
Solution
不难发现就是去掉可以用别的货币表示的货币。
# include <bits/stdc++.h>
using namespace std;
const int N = 105;
int T;
int n,a[N];
int can[25005];
int main(void)
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i = 1; i <= n; i++)
{
scanf("%d",&a[i]);
can[a[i]] = 1;
}
int m = 0;
for(int i = 1; i <= n; i++) m = max(m,a[i]);
for(int i = 1; i <= m; i++)
{
if(can[i])
{
for(int j = 1; j <= n; j++) if(i + a[j] <= m) can[i + a[j]] = 2;
}
}
int total = 0;
for(int i = 1; i <= n; i++) if(can[a[i]] == 2) ++total;
printf("%d\n",n - total);
for(int i = 1; i <= m; i++) can[i] = 0;
}
return 0;
}