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

运行 ID: 60340

#include <bits/stdc++.h> using namespace std; long long a[101010],b[101010],e[101010]; int main(){ // freopen("S2.in","r",stdin); // freopen("S2.out","w",stdout); int n,m,cnt = 0; cin>>n>>m; e[0] = 1; int num = 0; for (int i=1;i<=m;i++){ cin>>a[i]; b[i] = a[i]-1; e[++num] = a[num]*e[num-1]; } if (m == 0){ for (int i=1;i<=n;i++){ cout<<0<<" "; } return 0; } if (m == 1){ for (int i=1;i<=a[1];i++){ cout<<b[1]<<" "; } for (int i=a[1]+1;i<=n;i++){ cout<<b[1]*2<<" "; } return 0; } for (int i=1;i<=a[1];i++){ cnt++; cout<<a[1]+1<<" "; } for (int i=2;i<=n;i++){ for (int j=cnt+1;j<=e[i];j++) cout<<e[i]<<" "; } return 0; }