結果

問題 No.888 約数の総和
ユーザー junsuijunsui
提出日時 2019-09-27 14:27:13
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 715 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 54,892 KB
実行使用メモリ 7,680 KB
最終ジャッジ日時 2023-10-24 16:03:04
合計ジャッジ時間 6,443 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 11 ms
4,348 KB
testcase_19 AC 12 ms
4,348 KB
testcase_20 AC 7 ms
4,348 KB
testcase_21 AC 11 ms
4,348 KB
testcase_22 AC 79 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 71 ms
4,348 KB
testcase_25 AC 7 ms
4,348 KB
testcase_26 AC 1,637 ms
4,348 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>

#define rep( i, n, m ) for (int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for (int i = ( n ); i < ( m ); i--)

int main( void ){
	unsigned long long n;
	// if(!scanf( "%ld", &n ))
	//  return -1;
	std::cin >> n;
	if (n == 1){
		printf( "1\n" );
		return 0;
	}
	unsigned long long sum = 1 + n;
	unsigned long long max = n;
	unsigned long long a;
	// if (n % 2 == 0){
	//  sum += ( int )( n / 2 ) + 2;
	//  if (n == 4){
	//      sum-=2;
	//  }
	// }
	for(unsigned long long i = 2; i < max; i++){
		a = ( unsigned long long )( n / i );
		if (n - i * a == 0){
			sum += i + a;
			max = a;
			if (a == i)
				sum -= i;
		}
	}
	std::cout << sum << std::endl;
	return 0;
}
0