結果

問題 No.278 連続する整数の和(2)
ユーザー TwizzTwizz
提出日時 2017-05-21 11:32:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 471 bytes
コンパイル時間 1,496 ms
コンパイル使用メモリ 159,304 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 12:01:07
合計ジャッジ時間 2,490 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include"bits/stdc++.h"

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
const ll mod = 10000000000;

int main() {
	ll n;
	cin >> n;
	ll ans = 1;
	if (n != 1 && n % 2 == 1)ans += n;
	else { n /= 2; ans += n; }
	for (ll i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			ans += i;
			if (n / i != i)ans += n / i;
		}
	}
	
	print(ans);
	return 0;
}
0