Logo
(追記) (追記ここまで)

18070번 - Double Palindrome 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB54393587.500%

문제

A palindrome is a string that reads the same backward as forward. For example, rotator, lil and abba are palindromes, but shalash is not.

A double palindrome is a string that is either a palindrome or a concatenation of two (not necessarily distinct) palindromes. For example, susanna, potato and abba are double palindromes, but zzyzx and abaabb are not.

Dalila has just realized that her name is a double palindrome! Now she wonders how many non-empty strings of length at most n composed of the first k English letters have the same property. Help her find this number and output it modulo 998 244 353.

입력

The only line contains two integers n and k — the maximum length of the string and the size of the alphabet (1 ≤ n ≤ 105; 1 ≤ k ≤ 26).

출력

Output the number of non-empty double palindromes of length at most n composed of the first k English letters, modulo 998 244 353.

제한

예제 입력 1

3 3

예제 출력 1

33

예제 입력 2

6 2

예제 출력 2

114

예제 입력 3

42 7

예제 출력 3

83419789

힌트

In the first example the strings to be counted are: a, b, c, aa, ab, ac, ba, bb, bc, ca, cb, cc, aaa, aab, aac, aba, abb, aca, acc, baa, bab, bba, bbb, bbc, bcb, bcc, caa, cac, cbb, cbc, cca, ccb, ccc.

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2019-2020 North-Western Russia Regional Contest D번

(追記) (追記ここまで)

출처

대학교 대회

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

AltStyle によって変換されたページ (->オリジナル) /