結果

問題 No.2600 Avator Height
ユーザー Astral__Astral__
提出日時 2024-01-12 21:29:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 10,660 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 210,212 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-12 21:29:52
合計ジャッジ時間 5,751 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 38 ms
6,676 KB
testcase_02 AC 37 ms
6,676 KB
testcase_03 AC 38 ms
6,676 KB
testcase_04 AC 38 ms
6,676 KB
testcase_05 AC 38 ms
6,676 KB
testcase_06 AC 38 ms
6,676 KB
testcase_07 AC 40 ms
6,676 KB
testcase_08 AC 38 ms
6,676 KB
testcase_09 AC 37 ms
6,676 KB
testcase_10 AC 45 ms
6,676 KB
testcase_11 AC 37 ms
6,676 KB
testcase_12 AC 38 ms
6,676 KB
testcase_13 AC 39 ms
6,676 KB
testcase_14 AC 38 ms
6,676 KB
testcase_15 AC 38 ms
6,676 KB
testcase_16 AC 38 ms
6,676 KB
testcase_17 AC 38 ms
6,676 KB
testcase_18 AC 39 ms
6,676 KB
testcase_19 AC 39 ms
6,676 KB
testcase_20 AC 38 ms
6,676 KB
testcase_21 AC 38 ms
6,676 KB
testcase_22 AC 38 ms
6,676 KB
testcase_23 AC 39 ms
6,676 KB
testcase_24 AC 24 ms
6,676 KB
testcase_25 AC 34 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//using uLL = unsigned __int128;
using PT = priority_queue<tuple<ll, ll, ll>, vector<tuple<ll, ll, ll>>, greater<tuple<ll, ll, ll>>>;
using PPQ = priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>;
using PQ = priority_queue<ll, vector<ll>, greater<ll>>;
using P =  pair<ll, ll>;
using vvvvl = vector<vector<vector<vector<ll>>>>;
using vvvi = vector<vector<vector<int>>>;
using vvvl = vector<vector<vector<ll>>>;
using vvvc = vector<vector<vector<char>>>;
using vvvd = vector<vector<vector<double>>>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvs = vector<vector<string>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<pair<ll, ll>>>;
using vvb = vector<vector<bool>>;
using vvd = vector<vector<double>>;
using vp = vector<pair<ll, ll>>;
using vi = vector<int>;
using vl = vector<ll>;
using vu = vector<unsigned long long>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
#define vvvm  vector<vector<vector<mint>>>
#define vvm  vector<vector<mint>>
#define vm  vector<mint>
#define umap  unordered_map
#define uset  unordered_set
#define rrr(l, r) mt()%(r-l+1)+l
#define rep(i, s, f) for(long long i = s; i <= f; i++)
#define rep1(i, s, f) for(long long i = s; i <= f; i++)
#define per(i, s, f) for(long long i = s; i >= f; i--)
#define per1(i, s, f) for(long long i = s; i >= f; i--)
#define all0(x) (x).begin() ,(x).end()
#define all(x) (x).begin() + 1, (x).end()
#define ENDL '\n'
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//これが本当の組み込み関数ってね(笑)

template <typename T>
T or_less(vector<T> &A, T x) { //x以下で最大要素の添字 前提: sort済み 存在しない: -1
    return distance(A.begin(), upper_bound(A.begin(), A.end(), x)-1);
}
template <typename T>
T under(vector<T> &A, T x) { //x未満の最大要素の添字 前提: sort済み 存在しない: -1
    return distance(A.begin(), lower_bound(A.begin(), A.end(), x)-1);
}
template <typename T>
T or_more(vector<T> &A, T x) { //x以上で最小要素の添字  前提: sort済み 存在しない: 配列のサイズ .   //distanceのA.beginは添字を出すために常にA.begin() NG: A.begin() + 1
    return distance(A.begin(), lower_bound(A.begin(), A.end(), x));
}
template <typename T>
T over(vector<T> &A, T x) { //xより大きい最小要素の添字前提: sort済み 存在しない: 配列のサイズ
    return distance(A.begin(), upper_bound(A.begin(), A.end(), x));
}
template <typename T>
vector<T> vec_shift(vector<T> A, ll step, ll dir, ll indexed) {//dir = 1 : 右シフト  dir = -1 : 左シフト
    ll N = A.size() - indexed;
    vector<T> res(N+1);
    rep(i, indexed, N) {
        ll idx = i - step * dir;
        if(idx < indexed) idx += N;
        if(idx > N) idx -= N;
        res.at(i) = A.at(idx);
    }
    return res;
}
template <typename T>
void UNIQUE(vector<T> &A, int indexed) {
    sort(A.begin() + indexed, A.end());
    A.erase(unique(A.begin() + indexed, A.end()), A.end());
}
template <typename T>
vector<T> RLE(vector<T> &A, int indexed) {
   vector<T> res(indexed, -INT_MAX);
   for(int i = indexed; i < int(A.size()); i++) {
       if(i == indexed) res.push_back(A[i]);
       else if(A[i-1] != A[i]) res.push_back(A[i]);
   }
   return res;
}
template <typename T>
void rev90(vector<vector<T>> &A, int indexed) {
    reverse(A.begin() + indexed, A.end());
    int n = A.size();
    rep(i, indexed, n-1) {
        rep(j, i+1, n-1) {
            swap(A.at(i).at(j), A.at(j).at(i));
        }
    }
}
int msb(long long a) {
    if(a == 0) return -1;
    return 64 - int(__builtin_clzll(a));
}
template<typename T = long long>
void chmin(T &a, T b) {
    a = min(a, b);
}
template<typename T = long long>
void chmax(T &a, T b) {
    a = max(a, b);
}
//////////////////////////////////////////////////////////////////////
//数学系
///////////////////////////////////////////////////////////////////////
ll round(ll x, ll i) {return ll(x + 5 * powl(10, i-1))/ll(powl(10, i)) * ll(powl(10, i));}
vp insu_bunkai(ll N) {
    vp res;
    for (ll i = 2; i * i <= N; i++) {
        ll cnt = 0;
        while(N % i == 0) {
            cnt++;
            N /= i;
        }
        if(cnt != 0) res.push_back(P(i, cnt));
    }
    if(N != 1) res.push_back(P(N, 1));
    return res;
}
ll extgcd (ll a, ll b,  ll &x, ll &y) {
    if(b == 0) { x = 1;y = 0;return a;}
    ll d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
template <typename T>
T ceil(T a, T b) {
    assert(b != 0);
    if(a % b == 0) return a / b;
    if((a <= 0 && b < 0) || (a >= 0 && b > 0)) return a/b + 1;
    else return a / b;
}
template <typename T>
T floor(T a, T b) {
    assert(b != 0);
    if(a % b == 0) return a / b;
    if((a <= 0 && b < 0) || (a >= 0 && b > 0)) return a/b;
    else return a/b - 1;
}
long long Calnum(long long l, long long r, long long M, long long m) {//[l, r]で、modMがmである数の個数
    l -= m; r -= m;//並行移
    l = ceil(l, M) * M;
    r = floor(r, M) * M;
    if(l > r) return 0LL;
    return (r - l)/M+1;
}
ll modpow(ll x, ll y, ll mod) {
    if(x > mod) x %= mod;
    if(y == 0) return 1;
    ll res = modpow(x, y >> 1, mod);
    res = res * res % mod;
    if(y & 1) res *= x, res %= mod;
    return res;
}
ll sqrt_(ll a) {
    ll l = 0;
    ll r = 3037000499LL;
    while(l < r) {
        ll mid = (l + r + 1) / 2;
        if(mid * mid <= a) l = mid;
        else r = mid - 1;
    }
    return l;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//グローバル変数を置くところ(情報工学意識高め)
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
const ll int_max = 1001001001;
const ll ll_max = 1001001001001001001LL;
const double pi = 3.141592653589793;
vl dx{0, 1, 0, -1, 0, 1, 1, -1, -1};  // 座標平面において、(番兵) → ↓ ← ↑  ※ 右から時計回り 注 : グリッド or 座標で上下は反転する。
vl dy{0, 0, -1, 0, 1, 1, -1, -1, 1};
//const ll mod = 1000000007;
//const ll mod = 998244353;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct mint{//998244353
    long long x;
    static const long long mod = 998244353;
    mint(long long _x=0) noexcept : x((_x%mod+mod)%mod){}
    long long val() const noexcept {return x;}
    mint& operator+=(const mint& a) noexcept {if((x += a.x) >= mod) x -= mod;return *this;}
    mint& operator-=(const mint& a) noexcept {if((x += mod - a.x) >= mod) x -= mod;return *this;}
    mint& operator*=(const mint& a) noexcept {(x *= a.x) %= mod;return *this;}
    mint& operator/=(const mint& a) {return (*this) *= a.inv();}
    mint& operator++() noexcept {return *this += 1;}
    mint& operator--() noexcept {return *this -= 1;}
    mint operator++(int) {mint tmp = *this; ++*this; return tmp;}
    mint operator--(int) {mint tmp = *this; --*this; return tmp;}
    mint inv() const {return pow(mod-2);}
    friend mint operator+(const mint&  t, const mint& a)  {mint tmp = t; return tmp += a;}
    friend mint operator-(const mint&  t, const mint& a)  {mint tmp = t; return tmp += (a * -1);}
    friend mint operator*(const mint&  t, const mint& a)  {mint tmp = t; return tmp *= a;}
    friend mint operator/(const mint&  t, const mint& a)  {assert(a.x != 0) ; return a.inv() *=  t;}
    mint pow(const long long& y) const {
        if(!y) return 1;
        mint res = pow(y >> 1);
        res *= res;
        if(y & 1) res *= *this;
        return res;
    }
    friend istream& operator>>(istream& is, mint& a) { return is >> a.x;}
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
    bool operator==(const mint& a) const {return x == a.x;}
    bool operator!=(const mint& a) const {return x != a.x;}
    bool operator<(const mint& a) const {return x < a.x;}
};

void solve() {
    ll Q;
    cin >> Q;


    vm fib(200001,1);
    fib[0] = 0;
    rep(i,3,200002) fib[i] = fib[i-1] + fib[i-2];


    rep(qi, 1, Q) {
        ll n;
        cin >> n;
        if(n == 1) {
            cout << 4 << ENDL;
            continue;
        }

        if(n == 2) {
            cout << mint(5) - 9 << ENDL;
            continue;
        }
        
        mint res = fib[n]*fib[n]*5 - (3 * fib[n-1] +  fib[n-2]) * (3 * fib[n-1] +  fib[n-2]);
        cout << res << ENDL;

    }

    
    

}
//無闇にumapを使わない(特に平方分割時、必要ない事が多い(想定解が平方分割ならば))
//データを分割していく処理では、空配列は作らない方が良い(計算量爆発の温床)
//文字列を0-indexedで扱う時、全体の文字数をどう扱うかは最初に決める&忘れない
//場合分けが沢山の時はreturn忘れを確認
//LISは連続とは限らない。
//mintでも0で割っては行けない(例: 関数の合成とかでやりがち assert落ちする)
//負の数を/2してはいけない(それはfloorでないから)
//DPを書く時は、定義を常に明確にする!定義を変えたいと思ったならば、定義が定まるまでは"必要な情報"を考える。
//尺取り法的な事をする時は、rは勿論"lもNを超え無いようにする"事!(違反するとエラーコード139が出たりする)
//無断で0を平方数にカウントする人もいる
//”部分文字列”と”連続部分文字列”は違うので確認すること
//一般のグラフと、有向辺かつその貼り方に制約がある(多くの場合:番号がで解放に伸びる)はだいぶ違うので確認すること
//座標を2で割った時の”切り捨て側(左側)”を求めるには 誤:(x / 2) マイナスの時!!! 正:floor<ll>(x, 2);
//stringでの数字の下から1桁目は 正:S.at(N-1)  誤:S.at(0)
//if(S.at(i) == 1) ← charなのに1...?
// modは取りましたか...?(´・ω・`)
//sortの比較関数は、 a == b ならば falseを返す必要がある(そうで無いとRE(発生しない場合もある))



int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(15);
    ll T = 1;
    //cin >> T;
    rep(i, 1, T) {
        solve();
    }
  return 0;
}
0