結果

問題 No.278 連続する整数の和(2)
ユーザー koyumeishikoyumeishi
提出日時 2015-09-03 09:24:57
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 408 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 51,556 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-26 02:32:13
合計ジャッジ時間 2,138 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cassert>

long long s(long long n){
	long long ret = 1;
	for(long long i=2; i*i<=n; i++){
		if(n%i != 0) continue;
		long long tmp = i;
		while(n%i == 0){
			tmp *= i;
			n /= i;
		}
		ret *= (tmp-1)/(i-1);
	}
	if(n!=1){
		ret *= n+1;
	}
	return ret;
}

int main(){
	long long n;
	std::cin >> n;
	assert(1<=n && n<=1000000000000);
	std::cout << (n&1?s(n):s(n/2)) << std::endl;
}
0