結果
問題 | No.888 約数の総和 |
ユーザー |
|
提出日時 | 2019-09-26 06:36:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 863 ms |
コンパイル使用メモリ | 87,980 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-23 07:33:15 |
合計ジャッジ時間 | 1,909 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <stack> #include <map> #include <math.h> using namespace std; typedef long long int ll; template<typename T> map<T,ll> factorize(T x){ map<T,ll> res; for(ll i=2;i*i<=x;i++){ while(x%i==0){ x/=i; res[i]++; } } if(x!=1) res[x]++; return res; } int main(){ ll n; cin >> n; auto m=factorize(n); ll ans=1; for(auto x:m){ ll k=(pow(x.first,x.second+1)-1)/(x.first-1); ans*=k; } cout << ans << endl; }