結果

問題 No.2600 Avator Height
ユーザー weaken
提出日時 2024-01-25 13:54:34
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,376 bytes
コンパイル時間 2,680 ms
コンパイル使用メモリ 246,832 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-09-28 07:20:27
合計ジャッジ時間 6,259 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#ifdef DEBUG_
#include <compe/debug.hpp>
#else
#define dump(...)
#endif

#define FastIO cin.tie(nullptr), ios_base::sync_with_stdio(false);
#define rep(i, n) for (int i = 0; (int)i < n; ++i)
#define output(msg) cout << (msg) << '\n'
#define die(msg)         \
  do {                   \
    cout << msg << endl; \
    exit(0);             \
  } while (0)
#define INTi 1 << 30
#define INFll 1LL << 60

template <typename T> bool chmax(T& a, const T& b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T> bool chmin(T& a, const T& b) {
  return ((a > b) ? (a = b, true) : false);
}

using llint = long long int;
const llint MOD = 998244353;

llint mod(const llint& n) {
  return n % MOD;
}

void memoization(vector<llint>& memo, llint n, llint a, llint b) {
  memo[0] = a;
  memo[1] = b;
  for (int i = 2; i <= n; ++i) {
    memo[i] = mod(mod(memo[i - 1]) + mod(memo[i - 2]) + MOD);
  }
}

int main() {
  FastIO;
  int q;
  cin >> q;

  vector<llint> rmemo(200010, 0), ememo(200010, 0);
  memoization(ememo, 200005, 1, 3);
  memoization(rmemo, 200005, 1, 1);

  rep(i, q) {
    llint n;
    cin >> n;
    n--;

    llint r = mod(mod(rmemo[n]) * mod(rmemo[n]));
    llint e = mod(mod(ememo[n]) * mod(ememo[n]));
    llint ans = mod(mod((mod(r) * 5) - mod(e)) + MOD);
    dump(r, e, ans);
    output(ans);
  }
}
0