結果

問題 No.276 連続する整数の和(1)
ユーザー newlife171128newlife171128
提出日時 2018-01-28 19:39:41
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 603 bytes
コンパイル時間 1,149 ms
コンパイル使用メモリ 143,696 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 14:00:56
合計ジャッジ時間 3,335 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘ll gcd(ll, ll)’:
main.cpp:27:5: warning: control reaches end of non-void function [-Wreturn-type]
  gcd(b, a%b);
  ~~~^~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <utility>

typedef long long ll;
using namespace std;

typedef pair<int, int> P;

ll gcd(ll a, ll b){
	if(b==0){
		return a;
	}

	gcd(b, a%b);
}


int main() {

	ll n=0;
	cin>>n;

	ll a = (n+1)*(n/2);
	if(n%2 ==1){
		a += (n+1)/2;
	}

	ll b = a-1+n+1;

/*
	cout<<a<<endl;

	cout<<b<<endl;
*/

	cout<<gcd(b,a)<<endl;

	return 0;
}

0