結果

問題 No.658 テトラナッチ数列 Hard
ユーザー ngtkana
提出日時 2020-04-04 12:26:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 6,233 ms
コンパイル使用メモリ 196,792 KB
最終ジャッジ日時 2025-01-09 14:00:55
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint mod=17;
    std::vector<lint>a={1,0,0,0,1};
    while(true){
        if(std::vector<lint>(a.begin(),a.begin()+4)
            ==std::vector<lint>(a.end()-4,a.end()))break;
        a.push_back(std::accumulate(a.end()-4,a.end(),0ll)%mod);
    }
    lint sz=a.size()-4;
    lint q;std::cin>>q;
    while(q--){
        lint x;std::cin>>x;
        std::cout<<a.at(x%sz)<<'\n';
    }
}
0