結果

問題 No.831 都市めぐり
ユーザー aya_seaya_se
提出日時 2019-05-24 22:13:52
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 532 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 65,208 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 10:51:04
合計ジャッジ時間 1,269 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
//定義場所//
ll i, j, k, l, m, n;
ll N;
////////////

int main()
{
	cin >> N;
	ll ans = 0;
	if (N == 1) {
		cout << 0;
	}
	else {
		ll A = 1;
		ll B = N + (N - 1);
		ans += A * B;
		B--;
		A++;
		while (A <= (N / 2)) {
			ans += A * B;
			if (N%2==0&&A == (N / 2) - 1) {
				B--;
			}
			else {
				B -= 2;
			}
			A++;
		}
		if (N % 2 == 1) {
			ans += A * (A + 1);
		}
		cout << ans;
	}
}
0