結果

問題 No.276 連続する整数の和(1)
ユーザー wahr69
提出日時 2015-09-04 22:33:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 747 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 84,080 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 00:56:56
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

#include <array>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#include <string>
#include <sstream>

#include <memory>
#include <cassert>

#include <functional>

using namespace std;

const int MOD = 1000000007;

typedef unsigned long long ull;

int main()
{
	ull N;
	cin >> N;

	ull sum = 0ull;
	for (ull i = 0; i < N; ++i) {
		sum += i;
	}

	ull r;
	if( N < sum ) { r = N; N = sum; sum = r; }
      //ユークリッドの互除法により最大公約数を求める
        while( (r = N % sum) != 0 ) {
            N = sum;
            sum = r;
        }

	// sumが答え
	cout << sum << endl;
}
0