結果
問題 | No.657 テトラナッチ数列 Easy |
ユーザー |
![]() |
提出日時 | 2018-03-05 15:49:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 482 bytes |
コンパイル時間 | 578 ms |
コンパイル使用メモリ | 73,536 KB |
実行使用メモリ | 39,424 KB |
最終ジャッジ日時 | 2024-07-21 16:49:00 |
合計ジャッジ時間 | 1,581 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include<iostream> #include<vector> #include<bitset> #include<algorithm> #include<cmath> #include<string> using namespace std; #define ll long long ll memo[1000001]={}; ll tetora(ll n){ if(n<4) return 0; else if(n==4) return 1; if(memo[n]==0) memo[n] = (tetora(n-1)+tetora(n-2)+tetora(n-3)+tetora(n-4))%17; return memo[n]; } int main(){ ll Q,num; cin >> Q; while(Q--){ cin >> num; cout << tetora(num) << endl; } return 0; }