Revision en1, by judgeme, 2020-07-05 21:51:02

int main() { ll n;cin>>n; ll a[n]; for(int i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n,greater()); vector v; for(ll i=0;i<n;i++) { int flag = 0; v.PB(a[i]); for(ll j=0;j<n;j++) {

ll check = v.back();
       if( check%3==0 && binary_search(a,a+n,check/3)==true) v.PB(check/3);
       else if(binary_search(a,a+n,check*2)) v.PB(check*2);
       else {v.clear(); break;}
       if(v.size()==n){flag =1; break;}
   }
   if(flag==1) break;

} for(auto x:v) { cout<<x<<" "; } return 0; }

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English judgeme 2020-07-05 21:55:41 602
en1 English judgeme 2020-07-05 21:51:02 702 why this code is not printing anything?? (published)