結果

問題 No.831 都市めぐり
ユーザー iqueue02
提出日時 2020-07-15 12:14:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 2,805 ms
コンパイル使用メモリ 191,432 KB
最終ジャッジ日時 2025-01-11 21:04:47
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  ll n;
  cin >> n;
  ll res = 0;
  if (n == 1) {
    cout << res << endl;
    return 0;
  }
  if (n % 2 == 0) {
    res = n * n * n + 3 * n*n + 5*n - 6;
    res /= 6;
  } else {
    res = n * n * n + 3 * n*n + 5*n - 3;
    res /= 6;
  }
  cout << res << endl;
  return 0;
} 
0