题目大意就是给你n个数,然后要找这n个数的线性组合a1*x1+a2*x2+a3*x3+....+am*xm 等于任意正整数(1<=m<=n),问你这样的组合(a1,a2,...,am)有多少个,因为a1*x1+a2*x2+a3*x3+....+am*xm 等于任意正整数 ,然后任意正整数都是1的倍数,所以由裴蜀定理可知,选取的那m个数的gcd要为1才行,然后题目就转化为取若干个数gcd为1的方案数了,可以dp求,用的是刷表法
#include<bits/stdc++.h>
using namespace std;
#define ls rt<<1
#define rs (rt<<1)+1
#define PI acos(-1)
#define eps 1e-8
#define ll long long
#define fuck(x) cout<<#x<<" "<<x<<endl;
typedef pair<int,int> pii;
const int inf=2e9;
const int maxn=1e6+10;
int d[4][2]={1,0,-1,0,0,1,0,-1};
//int lowbit(int x){return x&-x;}
//void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);}
//int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;}
inline ll read() {
ll s = 0,w = 1;
char ch = getchar();
while(!isdigit(ch)) {
if(ch == '-') w = -1;
ch = getchar();
}
while(isdigit(ch))
s = s * 10 + ch - '0',ch = getchar();
return s * w;
}
inline void write(ll x) {
if(x < 0)
putchar('-'), x = -x;
if(x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
int mod=998244353;
int dp[3005][2005],a[3005];
int gcd(int x,int y){
return y==0?x:gcd(y,x%y);
}
int main(){
int n;
n=read();
for(int i=1;i<=n;i++)
a[i]=read();
dp[1][a[1]]=1;
dp[1][0]=1;
for(int i=1;i<n;i++)
for(int j=0;j<=2000;j++)
{
dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
dp[i+1][gcd(j,a[i+1])]=(dp[i+1][gcd(j,a[i+1])]+dp[i][j])%mod;
}
write(dp[n][1]);puts("");
return 0;
}