CodeFroces-- 514.div2.C-Sequence Transformation

题目链接 : 514.div2.C-Sequence Transformation

#include<bits/stdc++.h>
using namespace std;
#define maxn 1000011
int a[maxn];
int main(){
  int n;
  cin>>n;
  int y=1,t=0;
  while(n>1){
     int x=0,z;
     for(int j=2;j<=n;j++){
        if(n/j>=x){
           x=n/j;
           z=j;
        }
     }
     for(int j=1;j<=n;j++){
       if(j%z!=0){
          a[t++]=y;
       }
     }
     n/=z;
     y*=z;
  }
  a[t++]=y;
  for(int j=0;j<t;j++){
      cout<<a[j]<<" ";
  }
}

猜你喜欢

转载自www.cnblogs.com/DyLoder/p/9915264.html