結果

問題 No.3790 Unlabeled Slime Trees
コンテスト
ユーザー テナガザル
提出日時 2026-11-06 23:15:49
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 738 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,093 ms
コンパイル使用メモリ 172,360 KB
実行使用メモリ 26,852 KB
最終ジャッジ日時 2026-11-06 23:15:56
合計ジャッジ時間 5,477 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  const int mod = 998244353, b = 1e6, inv2 = 499122177;
  vector<long long> p2(b + 1), x(b + 1), y(b + 1);
  p2[0] = 1;
  for (int i = 0; i < b; ++i) p2[i + 1] = p2[i] * 2LL % mod;
  for (int i = 3; i <= b; ++i)
  {
    x[i] = (p2[i - 2] + mod - 1) % mod;
    y[i] = (p2[i - 2] - 1 + mod) * p2[i - 2] % mod * inv2 % mod + x[i - 1] * p2[i - 2] % mod * p2[i - 2] % mod + y[i - 1] * p2[i - 1] % mod * p2[i - 2] % mod;
    y[i] %= mod;
  }
  int t;
  cin >> t;
  while (t--)
  {
    int n;
    cin >> n;
    if (n < 3)
    {
      cout << 1 << '\n';
      continue;
    }
    long long ans = (x[n] + y[n] + 1)% mod;
    cout << ans << '\n';
  }
}
0