結果
| 問題 |
No.658 テトラナッチ数列 Hard
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-06 23:54:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 723 bytes |
| コンパイル時間 | 572 ms |
| コンパイル使用メモリ | 75,712 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 05:48:52 |
| 合計ジャッジ時間 | 1,308 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 |
ソースコード
#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
int main(void)
{
std::vector<int> t = { 0, 0, 0, 1 };
bool matched = false;
int i = 4;
while (!matched) {
t.push_back((t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17);
if (t[i] == 1 && t[i - 1] == 0 && t[i - 2] == 0 && t[i - 3] == 0) {
matched = true;
}
i = i + 1;
}
long long mod = i - 4;
int n;
long long a;
std::cin >> n;
for (i = 0; i < n; i++) {
std::cin >> a;
a--;
a %= mod;
std::cout << t[a] << std::endl;
}
return 0;
}