結果
| 問題 |
No.658 テトラナッチ数列 Hard
|
| コンテスト | |
| ユーザー |
ts_
|
| 提出日時 | 2018-04-06 04:44:25 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 2,000 ms |
| コード長 | 591 bytes |
| コンパイル時間 | 1,533 ms |
| コンパイル使用メモリ | 159,696 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 10:44:06 |
| 合計ジャッジ時間 | 2,084 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;
ll t[100001];
int main(){
t[0]=0,t[1]=0,t[2]=0,t[3]=1;
int cnt=4;
while(1){
t[cnt]=(t[cnt-1]+t[cnt-2]+t[cnt-3]+t[cnt-4])%17;
if(t[cnt]==1&&t[cnt-1]==0&&t[cnt-2]==0&&t[cnt-3]==0) break;
++cnt;
}
cnt-=3;
//cout<<cnt<<endl;
int q;
ll n;
cin>>q;
rep(i,q){
cin>>n;
--n;
cout<<t[n%cnt]<<endl;
}
return 0;
}
ts_