莫比乌斯函数,把所有的是i的倍数的数;num[i]如果大于四个就用C(4,num[i])*mu[i]就是答案
#include
#include
#include
#define ll long long
using namespace std;
const int MAX=11000;
int mu[MAX],n,max1;
int cnt[MAX];
int num[MAX];
void init()
{
memset(mu,0,sizeof(mu));
mu[1]=1;
for(int i=1;i= 4)
ans += (ll) mu[i] * x * (x - 1) * (x - 2) * (x - 3) / 24;
}
return ans;
}
int main()
{
init();
while(~scanf("%d",&n))
{
max1=0;
memset(cnt,0,sizeof(cnt));
memset(num, 0, sizeof(num));
for(int i = 0; i < n; i++)
{
int tmp;
scanf("%d", &tmp);
cnt[tmp] ++;
max1 = max(max1, tmp);
}
if(n<4)printf("0\n");
else printf("%lld\n",solve());
}
return 0;
}