結果

問題 No.831 都市めぐり
ユーザー aya_seaya_se
提出日時 2019-05-24 22:04:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 1,473 ms
コンパイル使用メモリ 65,164 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 12:36:21
合計ジャッジ時間 1,399 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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 (A == (N / 2) - 1) {
				B--;
			}
			else {
				B -= 2;
			}
			A++;
		}
		if (N % 2 == 1) {
			ans += ((N / 2) + 1) * ((N / 2) + 2);
		}
		cout << ans;
	}
}
0