Movatterモバイル変換


[0]ホーム

URL:


Logo

33369번 -Hardcore String Counting다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초2048 MB111100.000%

문제

You are given a non-empty string $s$ of lowercase English letters. A string $w$ of lowercase English letters isgood if every proper prefix of $w$ does not contain $s$ as a substring, but $w$ itself does.

Find the number of good strings of length $m$. Because this number can be very large, output it modulo prime number $998\,244\,353 = 2^{23} \cdot 119 + 1$.

입력

The first line of the input contains two integers: $n$, the length of $s$, and $m$, the length of strings you have to count ($1 \leq n \leq 10^5$, $n \leq m \leq 10^9$). The second line contains a string $s$ consisting of $n$ lowercase English letters.

출력

Output a single nonnegative integer: the number of good strings of length $m$ modulo $998\,244\,353$.

제한

예제 입력 1

6 7aaaaaa

예제 출력 1

25

예제 입력 2

3 5aba

예제 출력 2

675

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 4: SPb SU Contest, LVII SPb SU Championship M번

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일:contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호


[8]ページ先頭

©2009-2025 Movatter.jp