結果

問題 No.2600 Avator Height
ユーザー GOTKAKOGOTKAKO
提出日時 2024-01-13 17:53:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 2,035 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 203,832 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-13 17:53:33
合計ジャッジ時間 12,944 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,676 KB
testcase_01 AC 311 ms
6,676 KB
testcase_02 AC 316 ms
6,676 KB
testcase_03 AC 307 ms
6,676 KB
testcase_04 AC 305 ms
6,676 KB
testcase_05 AC 314 ms
6,676 KB
testcase_06 AC 302 ms
6,676 KB
testcase_07 AC 310 ms
6,676 KB
testcase_08 AC 308 ms
6,676 KB
testcase_09 AC 312 ms
6,676 KB
testcase_10 AC 311 ms
6,676 KB
testcase_11 AC 310 ms
6,676 KB
testcase_12 AC 321 ms
6,676 KB
testcase_13 AC 302 ms
6,676 KB
testcase_14 AC 300 ms
6,676 KB
testcase_15 AC 315 ms
6,676 KB
testcase_16 AC 304 ms
6,676 KB
testcase_17 AC 312 ms
6,676 KB
testcase_18 AC 305 ms
6,676 KB
testcase_19 AC 301 ms
6,676 KB
testcase_20 AC 298 ms
6,676 KB
testcase_21 AC 309 ms
6,676 KB
testcase_22 AC 319 ms
6,676 KB
testcase_23 AC 307 ms
6,676 KB
testcase_24 AC 279 ms
6,676 KB
testcase_25 AC 288 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long mod = 998244353;
//入力が必ずmod未満の時に使う.
struct mint{
    long long v = 0;
    mint(){} mint(int a){v = a;} mint(long long a){v = a;}
    long long val(){return v;}
    void modu(){v %= mod;}
 
    mint repeat2mint(long long a,long long b){
        mint ret = 1,p = a; int Log = 60;
        if(b <= 2e9) Log = 30;
        for(int i=0; i<Log; i++){if(b&(1LL<<i)) ret *= p; p *= p;}
        return ret;
    };
 
    mint operator+(mint b){return (v+b.v)%mod;}
    mint operator-(mint b){return (v-b.v+mod)%mod;}
    mint operator*(mint b){return v*b.v%mod;}
    mint operator/(mint b){
        if(b.v == 0) assert(false);
        return v*(repeat2mint(b.v,mod-2)).v%mod;
    }
 
    void operator+=(mint b){v = (v+b.v)%mod;}
    void operator-=(mint b){v = (v-b.v+mod)%mod;}
    void operator*=(mint b){v = v*b.v%mod;}
    void operator/=(mint b){
    if(b.v == 0) assert(false);
        v = v*repeat2mint(b.v,mod-2).v%mod;
    }
 
    void operator++(int){v = (v+1)%mod; return;}
    void operator--(int){v = (v-1+mod)%mod; return;}
    bool operator==(mint b){if(v == b.v) return true; else return false;}
    bool operator!=(mint b){if(v != b.v) return true; else return false;}
    bool operator>(mint b){if(v > b.v) return true; else return false;}
    bool operator>=(mint b){if(v >= b.v) return true; else return false;}
    bool operator<(mint b){if(v < b.v) return true; else return false;}
    bool operator<=(mint b){if(v <= b.v) return true; else return false;}
 
    mint pow(long long x){return repeat2mint(v,x);}
    mint inv(){return mint(1)/v;}
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    vector<mint> R(200001),E(200001);
    R.at(1) = 1,R.at(2) = 1;
    E.at(1) = 1,E.at(2) = 3;
    for(int i=3; i<=200000; i++) R.at(i) = R.at(i-1)+R.at(i-2),E.at(i) = E.at(i-1)+E.at(i-2);

    int Q; cin >> Q;
    while(Q--){
        int N; cin >> N;
        cout << (R.at(N)*R.at(N)*5-E.at(N)*E.at(N)).v << endl;
    }
}
0