結果

問題 No.375 立方体のN等分 (1)
ユーザー hogeover30
提出日時 2016-06-04 23:19:00
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 78,416 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-08 09:34:25
合計ジャッジ時間 1,827 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

map<long, int> func(long n)
{
    map<long, int> res;
    for(long i=2; i*i<=n; ++i) {
        int cnt=0;
        while (n%i==0) { ++cnt; n/=i; }
        if (cnt) res[i]+=cnt;
    }
    if (n>1) res[n]++;
    return res;
}

int main()
{
    long n;
    cin>>n;
    auto f=func(n);
    long res=0;
    for(auto& e: f) res+=(e.first-1)*e.second;
    cout<<res<<' '<<n-1<<endl;
}

0