1. 程式人生 > >CodeFroces-- 514.div2.C-Sequence Transformation

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]<<" "; } }