有人分析一下程序最坏情况下时间复杂度大概多少吗 qwq
#include<bits/stdc++.h>
#define ll int
#define F(i,j,n) for(int i=j;i<=n;i++)
#define B(i,j,n) for(int i=j;i>=n;i--)
#define Tr(v,e) for(int v:e)
#define D double
#define ps push_back
#define Test ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
using namespace std;
const int N=5e5+10,NN=1e4+10;
ll n,m,k,x,y,u,v,w,cnt=0,ans=0,t=0,l,r,len,T;
ll mn=INT_MAX,mx=0,Mod,id=1;
string s1,s2;
ll a[N],b[N],Can[N];
ll read(){
ll s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') {s=s*10+ch-'0';ch=getchar();}
return s*w;
}
inline void dfs(ll id,ll step){
if(!a[id]) ans++,cnt++;
a[id]=1;
if(b[id]) return ;
b[id]=1;
dfs((id+x)%n,step+1);
b[id]=0;
}
inline void write(ll x){
if(x<0) {putchar('-');x=-x;}
if(x>9) write(x/10);
putchar(x%10+'0');
}
inline void print(ll n){
F(i,1,n) write(0),putchar(' ');
return ;
}
int main(){
n=read(),m=read();
F(i,1,m){
ans=0;
x=read();
if(!Can[x]){
dfs(1,0);
F(i,1,n/x) Can[x*i]=1;
write(ans);
putchar(' ');
}
else write(0),putchar(' ');
if(cnt==n){
print(m-i);
return 0;
}
}
return 0;
}