結果

問題 No.891 隣接3項間の漸化式
ユーザー kat0rikkat0rik
提出日時 2019-09-21 13:48:41
言語 Go
(1.22.1)
結果
TLE  
実行時間 -
コード長 412 bytes
コンパイル時間 13,545 ms
コンパイル使用メモリ 227,336 KB
実行使用メモリ 12,172 KB
最終ジャッジ日時 2023-10-18 22:29:53
合計ジャッジ時間 19,395 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 50 ms
4,348 KB
testcase_04 AC 98 ms
4,348 KB
testcase_05 AC 102 ms
4,348 KB
testcase_06 AC 133 ms
4,348 KB
testcase_07 AC 94 ms
4,348 KB
testcase_08 AC 87 ms
4,348 KB
testcase_09 AC 114 ms
4,348 KB
testcase_10 AC 20 ms
4,348 KB
testcase_11 AC 55 ms
4,348 KB
testcase_12 AC 160 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 101 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 13 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 16 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import "fmt"

func main() {
	var a, b, n int
	var xn2, xn1, xn int
	xn1 = 1
	mod := int(1e9) + 7
	fmt.Scan(&a, &b, &n)
	if n == 0 {
		fmt.Println(0)
	} else if n == 1 {
		fmt.Println(1)
	} else {
		for i := 0; i < n-1; i++ {
			xn = ((a%mod)*(xn1%mod) + (b%mod)*(xn2%mod)) % mod
			// fmt.Printf("i %d, xn %d, xn1 %d, xn2 %d\n", i, xn, xn1, xn2)
			xn2 = xn1
			xn1 = xn
		}
		fmt.Println(xn)
	}
}
0