結果

問題 No.278 連続する整数の和(2)
ユーザー koyumeishikoyumeishi
提出日時 2015-09-03 09:25:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 51,604 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 22:33:27
合計ジャッジ時間 1,676 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,376 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 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 5 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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<=2000000000000);
	std::cout << (n&1?s(n):s(n/2)) << std::endl;
}
0