結果

問題 No.821 Making Integers
ユーザー chocopuuchocopuu
提出日時 2019-04-26 21:54:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,670 bytes
コンパイル時間 1,409 ms
コンパイル使用メモリ 165,284 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 14:03:08
合計ジャッジ時間 2,081 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
/*
#define endl '\n'
#define IOS()                     \
	ios_base::sync_with_stdio(0); \
	cin.tie(0)
*/
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
const long long MOD = 1000000007, INF = 1e18;
string get_str(string s)
{
	s += ',';
	string ret = "";
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == ',')
			ret += "=%ld, ";
		else
			ret += s[i];
	}
	return ret;
}
#define dump(...)                                       \
	printf(get_str(#__VA_ARGS__).c_str(), __VA_ARGS__); \
	cout << endl
//******************************************************************************

template <typename T>
vector<T>
make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
	for (auto &e : t)
		fill_v(e, v);
}

template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

signed main()
{
	int N, K;
	cin >> N >> K;
	int maxsum = (N + (N - K + 1)) * K / 2;
	int sum = (1 + N) * N / 2;
	dump(sum, maxsum);
	if (K % 2)
	{
		cout << maxsum + 1 << endl;
	}
	else
	{
		cout << maxsum - 1 << endl;
	}
}
0