結果

問題 No.2600 Avator Height
ユーザー umezo
提出日時 2024-01-12 23:48:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 191,988 KB
最終ジャッジ日時 2025-02-18 19:19:28
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

const int MOD=998244353;
ll r[200200],e[200200];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  r[1]=1,r[2]=1,e[1]=1,e[2]=3;
  for(int i=3;i<=200000;i++){
    r[i]=(r[i-1]+r[i-2])%MOD;
    e[i]=(e[i-1]+e[i-2])%MOD;
  }

  int q;
  cin>>q;
  while(q--){
    int n;
    cin>>n;
    if(n==1) cout<<4<<'\n';
    else if(n==2) cout<<MOD-4<<'\n';
    else{
      cout<<(5*r[n]%MOD*r[n]%MOD-e[n]*e[n]%MOD+MOD)%MOD<<'\n';
    }
  }
  
  return 0;
}
0