結果

問題 No.657 テトラナッチ数列 Easy
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-27 14:03:46
言語 Go
(1.22.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 493 bytes
コンパイル時間 13,576 ms
コンパイル使用メモリ 232,576 KB
実行使用メモリ 80,028 KB
最終ジャッジ日時 2024-04-19 09:53:42
合計ジャッジ時間 18,438 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 372 ms
79,764 KB
testcase_05 AC 16 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 405 ms
80,020 KB
testcase_09 AC 17 ms
6,940 KB
testcase_10 AC 28 ms
6,944 KB
testcase_11 AC 24 ms
6,940 KB
testcase_12 AC 167 ms
7,700 KB
testcase_13 AC 1,474 ms
80,024 KB
testcase_14 TLE -
testcase_15 AC 1,765 ms
80,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n, m int
	_, _ = fmt.Scan(&n)
	mod := 17

	sc := bufio.NewScanner(os.Stdin)
	nacci := map[int]int{1: 0, 2: 0, 3: 0, 4: 1}
	last := 4
	for i := 0; i < n; i++ {
		sc.Scan()
		m, _ = strconv.Atoi(sc.Text())

		if num, ok := nacci[m]; ok {
			fmt.Println(num)
		} else {
			for j := last + 1; j <= m; j++ {
				nacci[j] = (nacci[j-1] + nacci[j-2] + nacci[j-3] + nacci[j-4]) % mod
			}
			fmt.Println(nacci[m])
		}
	}
}
0