提交时间:2022-10-15 11:26:13

运行 ID: 60337

#include<bits/stdc++.h> using namespace std; int read() { int x=0; bool f=false; char t=getchar(); while(t<'0'||t>'9')f^=(t=='-'),t=getchar(); while(t>='0'&&t<='9')x=(x<<1)+(x<<3)+(t^48),t=getchar(); return f?-x:x; } const int N=1e5+10,M=1e5+10; int n,m,a[M],ans[N]; bool ok23=true,ok32=true; void write(int q) { if(q/10)write(q/10); putchar(q%10+48); } int main() { // freopen("S2.in","r",stdin); // freopen("S2.out","w",stdout); n=read(),m=read(); for(int i=1;i<=m;i++) a[i]=read(),ok23&=(i&1)?a[i]==2:a[i]==3,ok32=(i&1)?a[i]==3:a[i]==2; if(ok23) { if(m==1) ans[0]=2,ans[1]=2,ans[2]=4,ans[3]=4,ans[4]=6,ans[5]=6; else if(m==2) ans[0]=3,ans[1]=3,ans[2]=6,ans[3]=6,ans[4]=6,ans[5]=6; else if(m==3) ans[0]=4,ans[1]=4,ans[2]=6,ans[3]=6,ans[4]=6,ans[5]=6; else ans[0]=6,ans[1]=6,ans[2]=6,ans[3]=6,ans[4]=6,ans[5]=6; for(int i=1;i<=n;i++) write(ans[(i-1)%6]+(i-1)/6*6),putchar(' '); return 0; } if(ok32) { if(m==1) ans[0]=3,ans[1]=3,ans[2]=3,ans[3]=6,ans[4]=6,ans[5]=6; else if(m==2) ans[0]=4,ans[1]=4,ans[2]=4,ans[3]=6,ans[4]=6,ans[5]=6; else ans[0]=6,ans[1]=6,ans[2]=6,ans[3]=6,ans[4]=6,ans[5]=6; for(int i=1;i<=n;i++) write(ans[(i-1)%6]+(i-1)/6*6),putchar(' '); return 0; } for(int i=1;i<=n;i++) ans[i]=i; for(int i=1;i<=m;++i) for(int o=1;o<=n;++o) ans[o]=ans[o]-ans[o]%a[i]+(ans[o]%a[i]!=0)*a[i]; for(int i=1;i<=n;i++) write(ans[i]),putchar(' '); return 0; }