結果

問題 No.278 連続する整数の和(2)
ユーザー E31415926E31415926
提出日時 2016-04-05 17:08:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 58,652 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 22:47:14
合計ジャッジ時間 1,406 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<math.h>
using namespace std;
unsigned long long sumofx(unsigned long long a);

int main()
{
	unsigned long long n;
	cin >> n;
	cout << sumofx(n % 2 ? n : n / 2) << endl;
	return 0;
}

unsigned long long sumofx(unsigned long long a)
{
	unsigned long long ans=1, b=1, c=0,i;
	while (a % 2 == 0) {
		c++;
		b = b + pow(2, c);
		a /= 2;
	}
	ans *= b;
	for (i = 3; i <= sqrt(a); i+=2) {
		b = 1;
		c = 0;
		while (a%i == 0) {
			c++;
			b = b + pow(i, c);
			a /= i;
		}
		ans *= b;
	}
	if (a != 1)ans *= a + 1;
	return ans;
}
0