結果

問題 No.278 連続する整数の和(2)
ユーザー kotatsugamekotatsugame
提出日時 2020-02-22 08:12:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 346 bytes
コンパイル時間 642 ms
コンパイル使用メモリ 64,604 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 22:10:20
合計ジャッジ時間 1,608 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 14 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 18 ms
6,940 KB
testcase_09 AC 13 ms
6,944 KB
testcase_10 AC 16 ms
6,940 KB
testcase_11 AC 17 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 14 ms
6,940 KB
testcase_14 AC 10 ms
6,944 KB
testcase_15 AC 13 ms
6,944 KB
testcase_16 AC 11 ms
6,944 KB
testcase_17 AC 13 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
long X,ans;
long gcd(long a,long b){return b?gcd(b,a%b):a;}
bool f(long d)
{
	long L=d-1,R=X;
	if(L%2==0)L/=2;
	else R/=2;
	long g=gcd(L,d);
	d/=g;
	return R%d==0;
}
main()
{
	cin>>X;
	for(long i=1;i*i<=X;i++)
	{
		if(X%i==0)
		{
			if(f(i))ans+=i;
			if(i<X/i&&f(X/i))ans+=X/i;
		}
	}
	cout<<ans<<endl;
}
0