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

23140번 - Minimal Cyclic Shift 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 256 MB744100.000%

문제

Ani is a young and reckless student. One day, he got a really weird math homework.

In the homework, he was given $n$ strings $s_1, s_2, \ldots, s_n$ with length $a_1, a_2, \ldots, a_n,ドル respectively.

Define $f(s)$ as the position where the lexicographically minimal cyclic shift of $s$ starts. Since it may not be unique, $f(s)$ is defined as the minimal such position. For example, $f($"qweqweqwe"$) = 3,ドル because the lexicographically minimal cyclic shift of $s = $"qweqweqwe" is "eqweqweqw", and the minimal possible position where it starts in $s$ is position 3ドル$ where the first letter "e" is located.

The homework was to write down $f(s_1), f(s_2), f(s_3), \ldots, f(s_n),ドル in this order. But Ani's recklessness and the approaching of the deadline caused him to write the answers in the order $f(s_n), f(s_1), f(s_2), \ldots, f(s_{n-1})$.

Ani had not realized this until he submitted his answers. Now he can only remember $a_1, a_2, \ldots, a_n$. Assuming the given strings contain only lowercase English letters and were generated uniformly at random by the teacher, you need to help him calculate the expected number of correct answers in his homework modulo 998ドル,244円,353円$.

입력

The first line of input contains an integer $n$ (1ドル \le n \le 10^5$), the number of strings given in Ani's homework.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ (1ドル \le a_i \le 10^5$) separated by spaces, indicating the lengths of the strings.

출력

Print a single line with an integer: the expected number of correct answers in Ani's homework modulo 998ドル,244円,353円$.

Formally, it can be shown that the expected number of correct answers can be represented as a fraction $p / q$ for some coprime non-negative integers $p$ and $q$. You have to print the value $p \cdot q^{-1} \bmod 998,244円,353円$.

제한

예제 입력 1

5
3 1 5 2 4

예제 출력 1

727907401

예제 입력 2

1
100000

예제 출력 2

1

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 5: 2021 Shanghai ICPC Camp Onsite 2 by PKU C번

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

출처

대학교 대회

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

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