結果
問題 | No.657 テトラナッチ数列 Easy |
ユーザー |
|
提出日時 | 2018-06-07 14:02:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 533 bytes |
コンパイル時間 | 1,246 ms |
コンパイル使用メモリ | 159,264 KB |
実行使用メモリ | 35,712 KB |
最終ジャッジ日時 | 2024-06-30 10:29:24 |
合計ジャッジ時間 | 2,485 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long int ll; int memo[1000001]; int f(int n) { if (n <=3) return 0; else if (n == 4) return 1; else if (memo[n]) return memo[n]; else return memo[n] = (f(n-1)%17 + f(n-2)%17 + f(n-3)%17 + f(n-4)%17)%17; } int main() { cin.tie(0); ios::sync_with_stdio(false); int q; cin >> q; while (q--) { int t; cin >> t; cout << f(t) << endl; } return 0; }