結果

問題 No.278 連続する整数の和(2)
ユーザー satanicsatanic
提出日時 2016-04-02 14:26:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 1,026 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 72,036 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 22:47:05
合計ジャッジ時間 1,627 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 13 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 12 ms
4,376 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 15 ms
4,380 KB
testcase_11 AC 12 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 10 ms
4,376 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 12 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>

std::vector<std::pair<long long int, long long int>> PrimeFact(long long int n){
	std::vector<std::pair<long long int, long long int>> result;
	double sqrtn = std::sqrt(n);
	for(long long int i=2; i<sqrtn; ++i){
		int divCount = 0;
		if(n%i == 0){
			do{
				++divCount;
				n/=i;
			}while(n%i == 0);
		    result.push_back(std::make_pair(i, divCount));
		}
	}
    if(n!=1){
        result.push_back(std::make_pair(n, 1));
    }
	return result;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    long long int n, ans = 1;
    std::cin >> n;
    std::vector<std::pair<long long int, long long int>> p = PrimeFact((n%2==1) ? n : n/2);
    std::vector<long long int> sum(p.size(), 0);

    for(size_t i=0; i<p.size(); ++i){
        for(int j=0; j<=p[i].second; ++j){
            sum[i] += std::pow(p[i].first, j);
        }
        ans *= sum[i];
    }
    std::cout << ans << "\n";
    
    return 0;
}
0