結果
問題 |
No.3037 トグルトグルトグル!
|
ユーザー |
![]() |
提出日時 | 2025-04-15 23:46:00 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,231 bytes |
コンパイル時間 | 482 ms |
コンパイル使用メモリ | 81,740 KB |
実行使用メモリ | 66,896 KB |
最終ジャッジ日時 | 2025-04-15 23:48:39 |
合計ジャッジ時間 | 1,871 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 13 |
ソースコード
mod = (len('aaaaaaaaaa') ** len('aaaaaaaaa')) + len('aaaaaaa') one = len('a') zero = len('') two = len('aa') def multiply(m1, m2, mod): a = sum([m1[0][0].__mul__(m2[0][0]), m1[0][1].__mul__(m2[1][0])]).__mod__(mod) b = sum([m1[0][0].__mul__(m2[0][1]), m1[0][1].__mul__(m2[1][1])]).__mod__(mod) c = sum([m1[1][0].__mul__(m2[0][0]), m1[1][1].__mul__(m2[1][0])]).__mod__(mod) d = sum([m1[1][0].__mul__(m2[0][1]), m1[1][1].__mul__(m2[1][1])]).__mod__(mod) return [[a, b], [c, d]] def matrix_pow(mat, power, mod): result = [[one, zero], [zero, one]] current_power = power while current_power > zero: if current_power.__mod__(two) != zero: result = multiply(result, mat, mod) mat = multiply(mat, mat, mod) current_power = current_power.__floordiv__(two) return result T = int(input()) for _ in range(T): Ni = int(input()) if Ni == zero: print(two.__mod__(mod)) elif Ni == one: print(one.__mod__(mod)) else: power = Ni.__sub__(one) mat = matrix_pow([[one, one], [one, zero]], power, mod) v0 = one v1 = two a = sum([mat[0][0].__mul__(v0), mat[0][1].__mul__(v1)]).__mod__(mod) print(a)