这题有一个潜藏的性质

直接统计的因数,然后组合搞一下即可

记得这题要开(反正我开的int128)

//2*31*1847
//Copyright (c) 2019 by xiao_mmQF. All Rights Reserved.
#include<bits/stdc++.h>
#define int __int128
#pragma GCC optimize(3)
#define inl inline
#define reg register
#define db long double
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
inl int read(){ int x=0,f=0; char ch=0; while(!isdigit(ch))f|=(ch=='-'),ch=getchar(); while(isdigit(ch))(x*=10)+=(ch^48),ch=getchar(); return f?-x:x; }
inl void Ot(reg int x) { if(x<0)putchar('-'),x=-x; if(x>=10)Ot(x/10); putchar(x%10+'0'); }
inl void Print(reg int x,char til='\n'){Ot(x);putchar(til);}
inl int Max(reg int x,reg int y){return x>y?x:y;}
inl int Min(reg int x,reg int y){return x<y?x:y;}
inl int Abs(reg int x){return x<0?-x:x;}
int n;
int a,b,c,d,e,all,f;
int one,ans;
signed main() {
    n=read();
    for(reg int i=1;i<=n;i++)
    {
        int k=read();
        if(k==1)one++;
        if(k==2)a++;
        if(k==31)b++;
        if(k==1847)c++;
        if(k==31*1847)e++;
        if(k==31*2)d++;
        if(k==2*31*1847)all++;
        if(k==2*1847)f++;
    }
    if(all)ans+=one*all,ans+=all;
    if(d&&c)ans+=one*d*c,ans+=d*c;
    if(a&&b&&c)ans+=a*b*c,ans+=one*a*b*c;
    if(a&&e)ans+=a*e,ans+=one*a*e;
    if(b&&f)ans+=b*f,ans+=one*b*f;
    Print(ans);
    return 0 ;
}