結果
| 問題 | No.658 テトラナッチ数列 Hard |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-06 23:54:05 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 723 bytes |
| 記録 | |
| コンパイル時間 | 472 ms |
| コンパイル使用メモリ | 96,816 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-11 11:16:30 |
| 合計ジャッジ時間 | 1,047 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}