結果

問題 No.658 テトラナッチ数列 Hard
ユーザー 夜
提出日時 2021-02-11 18:36:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 893 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 100,100 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 08:20:18
合計ジャッジ時間 2,076 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 21 ms
4,380 KB
testcase_05 AC 21 ms
4,504 KB
testcase_06 AC 21 ms
4,376 KB
testcase_07 AC 21 ms
4,380 KB
testcase_08 AC 21 ms
4,380 KB
testcase_09 AC 23 ms
4,380 KB
testcase_10 AC 23 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
set<tuple<int, int, int, int>>st;
int t[5000];
int main() {
    t[0] = 0, t[1] = 0, t[2] = 0, t[3] = 1;
    int a = 0, b = 0, c = 0, d = 1;
    for (int i = 4; i < 100000; i++) {
        if (st.find(make_tuple(a, b, c, d)) != st.end()) {
            break;
        }
        st.insert(make_tuple(a, b, c, d));
        int a1 = b, b1 = c, c1 = d, d1 = a + b + c + d;
        d1 %= 17;
        t[i] = d1;
        a = a1, b = b1, c = c1, d = d1;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        long long n;
        cin >> n;
        n--;
        cout << t[n % 4912] << endl;
    }
}
0