結果

問題 No.888 約数の総和
ユーザー stg1048599
提出日時 2019-09-24 14:10:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 913 bytes
コンパイル時間 1,338 ms
コンパイル使用メモリ 168,444 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-19 05:07:10
合計ジャッジ時間 2,250 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(void){
    int n;
    cin >> n;
    auto m = prime_factor(n);
    vector<lli> sumv;
    for(auto i : m){
        lli sum = 0;
        for(int j = 0; j < i.second+1; j++){
            sum += pow(i.first, j);
        }
        sumv.push_back(sum);
    }
    lli res = 1;
    for(auto i : sumv) res*=i;
    cout << res << endl;
    return 0;
}
0