結果
問題 | No.3037 トグルトグルトグル! |
ユーザー |
![]() |
提出日時 | 2025-03-31 17:47:18 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,210 bytes |
コンパイル時間 | 191 ms |
コンパイル使用メモリ | 82,188 KB |
実行使用メモリ | 67,860 KB |
最終ジャッジ日時 | 2025-03-31 17:48:23 |
合計ジャッジ時間 | 1,825 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 13 |
ソースコード
import operator as o# Define numbers without using forbidden charactersz = len([])a = len([z])b = len([z, a])c = len([z, a, b])d = len([z, a, b, c])e = len([z, a, b, c, d])f = len([z, a, b, c, d, e])g = len([z, a, b, c, d, e, f])h = len([z, a, b, c, d, e, f, g])i = len([z, a, b, c, d, e, f, g, h])j = len([z, a, b, c, d, e, f, g, h, i])k = o.add(o.pow(j, i), g)# Matrix multiplication and exponentiation functionsdef mmul(m1, m2):return ((o.add(o.mul(m1[0][0], m2[0][0]), o.mul(m1[0][1], m2[1][0])) % k,o.add(o.mul(m1[0][0], m2[0][1]), o.mul(m1[0][1], m2[1][1])) % k),(o.add(o.mul(m1[1][0], m2[0][0]), o.mul(m1[1][1], m2[1][0])) % k,o.add(o.mul(m1[1][0], m2[0][1]), o.mul(m1[1][1], m2[1][1])) % k))def mpow(mat, power):result = ((a, z), (z, a))while power > z:if power % b == a:result = mmul(result, mat)mat = mmul(mat, mat)power = power // breturn resultdef lucas(n):if n == z:return b % kmat = mpow(((a, a), (a, z)), n - a)return o.add(o.mul(mat[0][0], a), o.mul(mat[0][1], b)) % kt = int(input())for _ in range(t):n = int(input())print(lucas(n))