倒计时68天

E-小红构造数组_牛客周赛 Round 29 (nowcoder.com)

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
map<int,int>mp;
void solve()
{
	int x;
    cin>>x;
    if(x==1){cout<<-1;return ;}
    vector<int>ve;
    for(int i=2;i*i<=x;i++)
    {
        while(x%i==0)
        {
            mp[i]++;
            x/=i;
        }
    }
    if(x!=1)mp[x]++;
    while(!mp.empty())
    {
        int a=-1,b=0;
        for(auto[x,y]:mp)
        {
            if(!ve.empty()&&x==ve.back())continue;
            if(y>b)a=x,b=y;
        }
        if(a==-1){cout<<-1;return ;}
        ve.push_back(a);
        mp[a]--;
        if(mp[a]==0)mp.erase(a);
    }
    cout<<ve.size()<<endl;
    for(auto i:ve)cout<<i<<' ';
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	solve();
	return 0;
}

相关推荐

  1. 计时68

    2024-02-01 17:28:02       40 阅读
  2. 计时68

    2024-02-01 17:28:02       44 阅读
  3. 计时67

    2024-02-01 17:28:02       34 阅读
  4. 计时65

    2024-02-01 17:28:02       27 阅读
  5. 计时64

    2024-02-01 17:28:02       36 阅读
  6. 计时80

    2024-02-01 17:28:02       32 阅读
  7. 计时57

    2024-02-01 17:28:02       37 阅读
  8. 计时56

    2024-02-01 17:28:02       35 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-01 17:28:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-01 17:28:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-01 17:28:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-01 17:28:02       20 阅读

热门阅读

  1. React16源码: React中处理ref的核心流程源码实现

    2024-02-01 17:28:02       32 阅读
  2. vue + 动态加载图片

    2024-02-01 17:28:02       44 阅读
  3. 如何在linux下使用openssl自签https的ip证书配置nginx

    2024-02-01 17:28:02       39 阅读
  4. MySQL进阶之存储过程(变量)

    2024-02-01 17:28:02       28 阅读
  5. ABAP EXCEL 转 PDF

    2024-02-01 17:28:02       27 阅读
  6. STM32——智能小车

    2024-02-01 17:28:02       28 阅读
  7. js中类型的值相加或相减的转换

    2024-02-01 17:28:02       30 阅读
  8. KY104 Pre-Post

    2024-02-01 17:28:02       39 阅读
  9. OpenGL着色器对象 Shader Objects

    2024-02-01 17:28:02       33 阅读
  10. Leetcode刷题(三十一)

    2024-02-01 17:28:02       30 阅读
  11. 【笔记ing】Helm-5 Chart模板指南-5 模板函数列表

    2024-02-01 17:28:02       34 阅读