倒计时68天

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

#include
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
mapmp;
void solve()
{
	int x;
    cin>>x;
    if(x==1){cout<<-1;return ;}
    vectorve;
    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<

你可能感兴趣的:(c++)