結果

問題 No.658 テトラナッチ数列 Hard
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2018-03-02 23:15:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,649 bytes
コンパイル時間 3,277 ms
コンパイル使用メモリ 164,776 KB
実行使用メモリ 7,632 KB
最終ジャッジ日時 2023-09-04 06:56:52
合計ジャッジ時間 2,584 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,400 KB
testcase_01 AC 9 ms
7,428 KB
testcase_02 AC 9 ms
7,412 KB
testcase_03 AC 9 ms
7,404 KB
testcase_04 AC 10 ms
7,424 KB
testcase_05 AC 11 ms
7,404 KB
testcase_06 AC 11 ms
7,632 KB
testcase_07 AC 11 ms
7,568 KB
testcase_08 AC 11 ms
7,428 KB
testcase_09 AC 12 ms
7,412 KB
testcase_10 AC 11 ms
7,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/
 







int T[1010101];
//---------------------------------------------------------------------------------------------------
void _main() {
    T[1] = 0;
    T[2] = 0;
    T[3] = 0;
    T[4] = 1;

    rep(i, 5, 1010101) T[i] = (T[i - 1] + T[i - 2] + T[i - 3] + T[i - 4]) % 17;

    int Q; cin >> Q;
    rep(q, 0, Q) {
        ll n; cin >> n;
        n--;

        n %= 4912;

        n++;

        printf("%d\n", T[n]);
    }
}
0