結果
| 問題 | 
                            No.888 約数の総和
                             | 
                    
| コンテスト | |
| ユーザー | 
                             misora192
                         | 
                    
| 提出日時 | 2019-10-07 07:39:00 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 5 ms / 2,000 ms | 
| コード長 | 787 bytes | 
| コンパイル時間 | 1,835 ms | 
| コンパイル使用メモリ | 169,808 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-12 12:42:50 | 
| 合計ジャッジ時間 | 2,833 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
vector<pll> prime_factorize(ll n) {
    vector<pll> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back((pll){p, num});
    }
    if (n != 1) res.push_back((pll){n, 1});
    return res;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll ans = 1LL;
	auto v = prime_factorize(n);
	for(auto pk : v){
		ll p = pk.first;
		ll k = pk.second;
		ll s = 0LL;
		ll t = 1LL;
		for(int i = 0; i < k+1; i++){
			s += t;
			t *= p;
		}
		// cout << p << "," <<  s << endl;
		ans *= s;
	}
	cout << ans << endl;
}
            
            
            
        
            
misora192