結果

問題 No.657 テトラナッチ数列 Easy
ユーザー むらためむらため
提出日時 2019-01-17 20:11:16
言語 Nim
(2.0.2)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 2,906 ms
コンパイル使用メモリ 68,048 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:04:58
合計ジャッジ時間 4,009 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 17 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 18 ms
4,380 KB
testcase_10 AC 18 ms
4,380 KB
testcase_11 AC 17 ms
4,376 KB
testcase_12 AC 18 ms
4,380 KB
testcase_13 AC 18 ms
4,376 KB
testcase_14 AC 18 ms
4,380 KB
testcase_15 AC 18 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 54) Warning: imported and not used: 'strformat' [UnusedImport]
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(1, 36) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 41) Warning: imported and not used: 'sugar' [UnusedImport]
/home/judge/data/code/Main.nim(1, 47) Warning: imported and not used: 'macros' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,algorithm,math,sugar,macros,strformat
template get*():string = stdin.readLine().strip()
template times*(n:int,body) = (for _ in 0..<n: body)
template `max=`*(x,y) = x = max(x,y)
template `min=`*(x,y) = x = min(x,y)

const t = (proc() : tuple[ts:seq[int],n:int] =
  var (a,b,c,d) = (0,0,0,1)
  var n = 0
  var ts = @[0,0,0,0,1]
  while true:
    (a,b,c,d) = (b,c,d,(a+b+c+d) mod 17)
    if a == 0 and b == 0 and c == 0 and d == 1 : break
    n += 1
    ts &= d
  return (ts,n)
)()
proc getTet(n:int):int =
  if n < t.ts.len  : return t.ts[n]
  return t.ts[4 + (n-4) mod (t.ts.len - 4)]

let q = get().parseInt()
q.times: echo get().parseInt().getTet()
0