結果

問題 No.888 約数の総和
ユーザー data9824data9824
提出日時 2019-11-30 15:58:23
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 932 bytes
コンパイル時間 1,045 ms
コンパイル使用メモリ 66,092 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-08-13 08:24:58
合計ジャッジ時間 6,975 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 90 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 78 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1,843 ms
4,380 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>

using namespace std;

long long sum(map<long long, long long>::const_iterator itBegin,
              map<long long, long long>::const_iterator itEnd,
              long long base) {
    if (itBegin == itEnd) {
        return base;
    }
    map<long long, long long>::const_iterator itNext = itBegin;
    ++itNext;
    long long result = 0;
    long long powered = 1;
    for (long long i = 0; i <= itBegin->second; ++i) {
        result += sum(itNext, itEnd, base * powered);
        powered *= itBegin->first;
    }
    return result;
}

int main(int argc, const char * argv[]) {
    long long n;
    cin >> n;
    map<long long, long long> factors;
    for (long long divider = 2; divider <= n; ++divider) {
        while (n % divider == 0) {
            ++factors[divider];
            n /= divider;
        }
    }
    cout << sum(factors.begin(), factors.end(), 1) << endl;
    return 0;
}
0