結果
問題 | No.2156 ぞい文字列 |
ユーザー | terasa |
提出日時 | 2022-12-09 22:06:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 1,473 bytes |
コンパイル時間 | 320 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 68,736 KB |
最終ジャッジ日時 | 2024-04-22 22:14:43 |
合計ジャッジ時間 | 2,638 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
68,352 KB |
testcase_01 | AC | 76 ms
68,480 KB |
testcase_02 | AC | 76 ms
68,480 KB |
testcase_03 | AC | 77 ms
68,480 KB |
testcase_04 | AC | 80 ms
68,608 KB |
testcase_05 | AC | 76 ms
68,352 KB |
testcase_06 | AC | 79 ms
68,480 KB |
testcase_07 | AC | 75 ms
68,736 KB |
testcase_08 | AC | 75 ms
68,352 KB |
testcase_09 | AC | 74 ms
68,224 KB |
testcase_10 | AC | 74 ms
68,096 KB |
testcase_11 | AC | 76 ms
68,096 KB |
testcase_12 | AC | 74 ms
68,224 KB |
testcase_13 | AC | 75 ms
68,224 KB |
testcase_14 | AC | 75 ms
68,224 KB |
testcase_15 | AC | 76 ms
68,480 KB |
testcase_16 | AC | 76 ms
68,096 KB |
testcase_17 | AC | 78 ms
68,608 KB |
testcase_18 | AC | 77 ms
68,480 KB |
testcase_19 | AC | 75 ms
68,480 KB |
ソースコード
from typing import List, Tuple, Callable, TypeVar, Optional import sys import itertools import heapq import bisect import math from collections import deque, defaultdict from functools import lru_cache, cmp_to_key input = sys.stdin.readline if __file__ != 'prog.py': sys.setrecursionlimit(10 ** 6) def readints(): return map(int, input().split()) def readlist(): return list(readints()) def readstr(): return input()[:-1] class Matpow: def __init__(self, A, mod, digit=60): self.A = A self.N = len(A) self.mod = mod self.digit = digit self.doubling = [None] * self.digit self.doubling[0] = A for i in range(1, self.digit): self.doubling[i] = self.mul(self.doubling[i - 1], self.doubling[i - 1]) def pow(self, n): E = [[1 if i == j else 0 for j in range(self.N)] for i in range(self.N)] acc = E for k in range(self.digit): if n & (1 << k): acc = self.mul(acc, self.doubling[k]) return acc def mul(self, A, B): C = [[0 for _ in range(self.N)] for _ in range(self.N)] for i in range(self.N): for j in range(self.N): for k in range(self.N): C[i][j] += A[i][k] * B[k][j] C[i][j] %= self.mod return C N = int(input()) mod = 998244353 A = [[1, 1], [1, 0]] An = Matpow(A, mod).pow(N - 1) ans = (sum(An[0]) - 1) % mod print(ans)