結果

問題 No.831 都市めぐり
ユーザー warabi0906warabi0906
提出日時 2023-02-10 13:35:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,790 bytes
コンパイル時間 4,367 ms
コンパイル使用メモリ 228,524 KB
実行使用メモリ 18,772 KB
最終ジャッジ日時 2023-09-21 16:17:46
合計ジャッジ時間 4,876 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 6 ms
9,476 KB
testcase_16 AC 4 ms
5,656 KB
testcase_17 AC 7 ms
10,680 KB
testcase_18 AC 8 ms
13,048 KB
testcase_19 AC 11 ms
18,180 KB
testcase_20 AC 11 ms
18,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include "atcoder/all"
#define debug cout << "OK" << endl;
template<typename T>
inline bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
inline bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }
inline int Code(char c) {
	if ('A' <= c and c <= 'Z')return (int)(c - 'A');
	if ('a' <= c and c <= 'z')return (int)(c - 'a');
	if ('0' <= c and c <= '9')return (int)(c - '0');
	assert(false);
}
using namespace std;
using namespace atcoder;
#define int long long
constexpr int MOD = 998244353;
constexpr int INF = (1LL << 63);
using minit = modint998244353;

template<typename T>
ostream& operator << (ostream& st, const vector<T>& v) {
	for (const T value : v) {
		st << value << " ";
	}
	return st;
}
template<typename T>
istream& operator >> (istream& st, vector<T>& v) {
	for (T& value : v) {
		st >> value;
	}
	return st;
}

struct edge {
	int to, cost;
};

//

//

class Solver {
public:
	int T;
	Solver() :T(1) {}
	~Solver(){}
	void multi();
	void solve() const;
	void sp(int x)const;
};
void Solver::multi() {
	cin >> T;
	return;
}
void Solver::sp(const int x)const {
	cout << fixed << setprecision(x) << endl;
	return;
}

void Solver::solve() const {
	int N;
	cin >> N;
	if (N == 1) {
		cout << 0 << endl; return;
	}
	vector<int> res(N);
	iota(res.begin(), res.end(), 1);
	for (int i = 0; i < N / 2; i++) {
		if (i % 2)swap(res[i], res[N - i - 1]);
	}

	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		ans += res[i] * res[i + 1];
	}
	cout << ans + N << endl;
}

signed main() {
	Solver solver;
	//solver.multi();
	//solver.sp();
	for (int i = 0; i < solver.T; i++)
		solver.solve();
	return 0;
}

/*
* わらびのコードこーどすぺーす
 (σ・∀・)σゲッツ!!
*/
0