結果
| 問題 |
No.658 テトラナッチ数列 Hard
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-11 18:36:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 893 bytes |
| コンパイル時間 | 790 ms |
| コンパイル使用メモリ | 101,796 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-18 06:51:06 |
| 合計ジャッジ時間 | 1,754 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 |
ソースコード
#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;
}
}