結果
問題 | No.657 テトラナッチ数列 Easy |
ユーザー |
|
提出日時 | 2020-04-16 09:49:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 546 bytes |
コンパイル時間 | 646 ms |
コンパイル使用メモリ | 71,388 KB |
最終ジャッジ日時 | 2025-01-09 19:25:08 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <iostream> #include <vector> constexpr int N = 1000000; constexpr int MOD = 17; void solve() { std::vector<int> xs(N + 1, 0); xs[4] = 1; for (int i = 5; i <= N; ++i) { for (int j = 1; j <= 4; ++j) { xs[i] += xs[i - j]; } xs[i] %= MOD; } int q; std::cin >> q; while (q--) { int n; std::cin >> n; std::cout << xs[n] << std::endl; } } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }