結果

問題 No.376 立方体のN等分 (2)
ユーザー imulan
提出日時 2016-12-07 20:06:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 1,823 ms
コンパイル使用メモリ 174,704 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-28 03:27:28
合計ジャッジ時間 5,372 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

vector<ll> factorize(ll n)
{
    vector<ll> ret;

    ll t=n;
    for(ll i=2; i*i<=n; ++i)
    {
        while(t%i==0)
        {
            t/=i;
            ret.pb(i);
        }
    }
    if(t>1) ret.pb(t);
    sort(all(ret),greater<ll>());
    return ret;
}

int main()
{
    ll n;
    cin >>n;

    ll tmin=0,tmax=n-1;

    priority_queue<ll,vector<ll>,greater<ll>> que;
    rep(i,3) que.push(1);

    vector<ll> d=factorize(n);
    for(const auto &x:d)
    {
        ll v=que.top();
        que.pop();
        v*=x;
        que.push(v);
    }

    while(!que.empty())
    {
        ll v=que.top();
        que.pop();
        tmin+=v-1;
    }

    cout << tmin << " " << tmax << endl;
    return 0;
}
0