AcWing 4211. 序列重排
#include#include#includeusing namespace std;const int N = 1e3 + 10;typedef long long ll;typedef pair PII;int n;ll get (ll a, ll b) {  ll res = 0;  while(a % b == 0) res ++, a /= b;  return res;}struct Node {  ll x, y, z;  bool operator< (const Node &q) {    if (x != q.x) return x < q.x;    else return y < q.y;  }}q[N];void solve() {  cin >> n;  for (int i =1; i<= n; i ++) {    ll t;    cin >> t;    q[i].x = get(t, 2), q[i].y = -get(t, 3), q[i].z = t;  }  sort(q+ 1, q + 1 + n);  for (int i= 1; i<= n; i++) {    cout << q[i].z << " ";  }  puts("");}int main () {  int t;  t =1;  while (t --) solve();  return 0;}
从2,3因子的角度想,对于一个合法的序列 xi < xj huo yi > yj && xi==xj 且是唯一的反证法
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。