結果
問題 |
No.657 テトラナッチ数列 Easy
|
ユーザー |
![]() |
提出日時 | 2019-03-27 14:28:01 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 402 ms / 2,000 ms |
コード長 | 505 bytes |
コンパイル時間 | 14,769 ms |
コンパイル使用メモリ | 223,240 KB |
実行使用メモリ | 79,872 KB |
最終ジャッジ日時 | 2024-10-11 02:20:54 |
合計ジャッジ時間 | 13,707 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
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 } last = m fmt.Println(nacci[m]) } } }