結果

問題 No.1824 門\松\列
ユーザー cumincumin
提出日時 2022-01-28 21:46:30
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 3,383 bytes
コンパイル時間 4,175 ms
コンパイル使用メモリ 260,592 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 19:38:35
合計ジャッジ時間 4,781 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 18 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;


//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/tag_and_trait.hpp>
//using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define rrep2(i, a, b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define eb emplace_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define endl '\n'
template<class T> using pq = priority_queue< T >;
template<class T> using pqg = priority_queue< T , vector< T >, greater< T >>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll digit(ll x){
  string s = to_string(x);
  return (ll)s.size();
}
#define debug(arg) print(#arg, arg)

// std::cerr << arg が元々使えるやつはそれを使う
template <class Tp> void out(Tp arg) {
  std::cerr << arg;
}
// std::pair の出力
template <class Tp1, class Tp2> void out(std::pair<Tp1, Tp2> arg) {
  std::cerr << '(';
  out(arg.first);
  std::cerr << ", ";
  out(arg.second);
  std::cerr << ')';
}
// std::tuple の出力
template <class T, std::size_t... Is> void print_tuple(T arg, std::index_sequence<Is...>) {
  static_cast<void>(((std::cerr << (Is == 0 ? "" : ", "), out(std::get<Is>(arg))), ...));
}
template <class... Ts> void out(std::tuple<Ts...> arg) {
  std::cerr << '(';
  print_tuple(arg, std::make_index_sequence<sizeof...(Ts)>());
  std::cerr << ')';
}
// std::{vector, deque, forward_list, list, initializer_list, set, multiset, unordered_set, unordered_multiset, map, multimap, unordered_map, unordered_multimap, valarray} の出力
template <template <class...> class Container, class... Ts>
void out(Container<Ts...> arg) {
  std::cerr << "[ ";
  std::for_each(std::cbegin(arg), std::cend(arg), [](typename Container<Ts...>::value_type elem) {
    out(elem);
    std::cerr << ' ';
  });
  std::cerr << ']';
}
// std::array の出力
template <class Tp, std::size_t N> void out(std::array<Tp, N> arg) {
  std::cerr << "[ ";
  std::for_each(std::cbegin(arg), std::cend(arg), [](Tp elem) {
    out(elem);
    std::cerr << ' ';
  });
  std::cerr << ']';
}

template <class Tp> void print(std::string_view name, Tp arg) {
  std::cerr << name << ": ";
  out(arg);  // out 関数を使うように変更
  std::cerr << '\n';
}

const int inf = 1001001001;
const ll INF = 1001001001001001001;

const double PI = acos(-1);

bool range(int y, int x, int h, int w){
  return (0 <= y && y < h && 0 <= x && x < w);
}
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

using mint = modint998244353;
const int MOD = 998244353;
//using mint = modint1000000007;
//const int MOD = 1000000007;


signed main(){
  cout << fixed << setprecision(15);
  
  int T;
  cin >> T;
  while(T--){
    ll N;
    cin >> N;
    ll ans = (N*N-N+2)*N - (N+1)*(N+1)*N + N*(N+1)*(2*N+1)/3;
    cout << ans << endl;
  }
  return 0;
}
0