結果
| 問題 |
No.657 テトラナッチ数列 Easy
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-16 16:59:55 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 658 bytes |
| コンパイル時間 | 730 ms |
| コンパイル使用メモリ | 103,296 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2024-06-13 00:29:58 |
| 合計ジャッジ時間 | 1,313 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;
void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
const mod = 17;
void main()
{
int q; readV(q);
int[] n; readC(q, n);
auto mn = max(n.maxElement, 4);
auto t = new int[](mn+1);
t[4] = 1;
foreach (i; 5..mn+1)
t[i] = (t[i-1]+t[i-2]+t[i-3]+t[i-4])%mod;
foreach (i; 0..q)
writeln(t[n[i]]);
}