結果

問題 No.276 連続する整数の和(1)
ユーザー syoken_desukasyoken_desuka
提出日時 2015-09-04 22:52:22
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 2,097 bytes
コンパイル時間 1,376 ms
コンパイル使用メモリ 158,608 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-19 01:29:30
合計ジャッジ時間 1,574 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:27:9: warning: ISO C++11 requires whitespace after the macro name
   27 | #define DEBUG1{}
      |         ^~~~~~
main.cpp:27: warning: "DEBUG1" redefined
   27 | #define DEBUG1{}
      | 
main.cpp:22: note: this is the location of the previous definition
   22 | #define DEBUG1(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
      | 
main.cpp:28:9: warning: ISO C++11 requires whitespace after the macro name
   28 | #define DEBUG2{}
      |         ^~~~~~
main.cpp:28: warning: "DEBUG2" redefined
   28 | #define DEBUG2{}
      | 
main.cpp:23: note: this is the location of the previous definition
   23 | #define DEBUG2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG1(var1); }
      | 
main.cpp:29:9: warning: ISO C++11 requires whitespace after the macro name
   29 | #define DEBUG3{}
      |         ^~~~~~
main.cpp:29: warning: "DEBUG3" redefined
   29 | #define DEBUG3{}
      | 
main.cpp:24: note: this is the location of the previous definition
   24 | #define DEBUG3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG2(var1, var2); }
      | 
main.cpp:30:9: warning: ISO C++11 requires whitespace after the macro name
   30 | #define DEBUG4{}
      |         ^~~~~~
main.cpp:30: warning: "DEBUG4" redefined
   30 | #define DEBUG4{}
      | 
main.cpp:25: note: this is the location of the previous definition
   25 | #define DEBUG4(var0, var1, var2, var3) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG3(var1, var2, var3); }
      | 

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
//諸機能
#pragma region MACRO
#define ANSWER(x) cerr << "answer: "; cout << (x) << endl
#define DOUBLE_ANSWER(x) cerr << "answer: "; cout << setprecision(10) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define ALL(a) begin((a)),end((a))
#define FILL(a,n) for(auto &hoge : (a)) hoge = (n)
#define mp make_pair
#define EXIST(container, n) ((container).find((n)) != (container).end())
#define STOI(s,i,l) stoi(SUBSTR(s,i,l))
#define SUBSTR(s,i,l) string((s), (i), (l))
#define NPI_TO_RAD(x) (180.0*x/PI)
#define RAD_TO_NPI(x) (PI/180.0*x)
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define DEBUG1(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define DEBUG2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG2(var1, var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; DEBUG3(var1, var2, var3); }
#ifndef _DEBUG //デバッグでないなら、計算時間短縮のためにエラー出力を無効化
#define DEBUG1{}
#define DEBUG2{}
#define DEBUG3{}
#define DEBUG4{}
#endif
//typedef(書き換える、書き足す可能性ある)
#pragma region TYPE_DEF
typedef long long ll; 
typedef pair<int,int> pii;
typedef pair<string,string> pss;
typedef pair<int,string>pis;
typedef pair<string,int>psi;
typedef vector<string> vs;
typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9 + 7)
#pragma endregion

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

int main()
{
	ll n;
	cin >> n;
	if (n == 1)
	{
		ANSWER(1);
	}
	else
	{
		ll tumitate = n*( n -1 ) / 2;
		ll x = gcd(n, tumitate);
		ANSWER(x);
	}
	return 0;
}
0