結果

問題 No.657 テトラナッチ数列 Easy
ユーザー rogi52rogi52
提出日時 2022-09-28 19:02:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 1,903 ms
コンパイル使用メモリ 198,888 KB
実行使用メモリ 6,964 KB
最終ジャッジ日時 2023-08-24 04:33:00
合計ジャッジ時間 3,110 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,964 KB
testcase_01 AC 8 ms
6,928 KB
testcase_02 AC 8 ms
6,712 KB
testcase_03 AC 8 ms
6,820 KB
testcase_04 AC 8 ms
6,824 KB
testcase_05 AC 9 ms
6,856 KB
testcase_06 AC 8 ms
6,716 KB
testcase_07 AC 8 ms
6,824 KB
testcase_08 AC 9 ms
6,860 KB
testcase_09 AC 9 ms
6,868 KB
testcase_10 AC 10 ms
6,896 KB
testcase_11 AC 10 ms
6,756 KB
testcase_12 AC 10 ms
6,752 KB
testcase_13 AC 10 ms
6,816 KB
testcase_14 AC 10 ms
6,820 KB
testcase_15 AC 11 ms
6,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int MAX_N = 1010101;
    vector<int> dp(MAX_N + 1, 0);
    dp[1] = 0, dp[2] = 0, dp[3] = 0, dp[4] = 1;
    for(int i = 5; i <= MAX_N; i++) dp[i] = (dp[i - 1] + dp[i - 2] + dp[i - 3] + dp[i - 4]) % 17;

    int Q; cin >> Q;
    rep(_,Q) {
        int n; cin >> n;
        cout << dp[n] << "\n";
    }
}
0