// No.657 テトラナッチ数列 Easy // https://yukicoder.me/problems/no/657 // #include #include #include #include #include using namespace std; vector solve(int &limit); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); unsigned int Q; cin >> Q; vector queries(Q); for (auto i = 0; i < Q; ++i) cin >> queries[i]; vector tetra = solve(*max_element(queries.begin(), queries.end())); for (auto q: queries) cout << tetra[q] << endl; } vector solve(int &limit) { vector res {-1, 0, 0, 0, 1}; for (auto i = 5; i <= limit; ++i) { int tmp = accumulate(res.end()-4, res.end(), 0) % 17; res.emplace_back(tmp); } return res; }