Submission #35073839


Source Code Expand

MOD=998244353
N=int(input())
A=list(map(int,input().split()))
e=[0]*(N)
s=0
Ninv=pow(N,-1,MOD)%MOD
for i in range(1,N):
  p=(N-i)*Ninv
  c=A[-i]-A[-(i+1)]
  pp=N*pow(i,-1,MOD)%MOD  # 1/(1-p)
  pc=pow(p,c,MOD)
  e[-(i+1)]=(Ninv*(1-pc)*pp*s+pp*(1-(c+1)*pc+c*p*pc)+c*pc-e[-i])*-pow(pc,-1,MOD)%MOD
  s+=e[-(i+1)]

print(-e[0]%MOD)

Submission Info

Submission Time
Task Ex - add 1
User kyopro_friends
Language Python (3.8.2)
Score 600
Code Size 342 Byte
Status AC
Exec Time 1884 ms
Memory 37568 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 40
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 18 ms 8880 KiB
example_01.txt AC 20 ms 8876 KiB
hand_00.txt AC 17 ms 9088 KiB
hand_01.txt AC 17 ms 8960 KiB
hand_02.txt AC 718 ms 37568 KiB
hand_03.txt AC 682 ms 18232 KiB
hand_04.txt AC 1773 ms 33036 KiB
hand_05.txt AC 18 ms 9052 KiB
hand_06.txt AC 19 ms 9132 KiB
hand_07.txt AC 18 ms 9160 KiB
random_00.txt AC 1849 ms 36212 KiB
random_01.txt AC 1879 ms 33988 KiB
random_02.txt AC 1872 ms 34544 KiB
random_03.txt AC 1868 ms 33832 KiB
random_04.txt AC 1884 ms 36072 KiB
random_05.txt AC 1874 ms 34704 KiB
random_06.txt AC 1866 ms 34740 KiB
random_07.txt AC 1859 ms 33824 KiB
random_08.txt AC 1868 ms 34080 KiB
random_09.txt AC 1867 ms 33892 KiB
random_10.txt AC 1185 ms 34120 KiB
random_11.txt AC 1183 ms 36148 KiB
random_12.txt AC 1238 ms 34000 KiB
random_13.txt AC 1191 ms 36240 KiB
random_14.txt AC 1201 ms 33844 KiB
random_15.txt AC 1208 ms 36380 KiB
random_16.txt AC 1194 ms 36436 KiB
random_17.txt AC 1171 ms 36424 KiB
random_18.txt AC 1231 ms 34052 KiB
random_19.txt AC 1187 ms 34156 KiB
random_20.txt AC 1186 ms 33928 KiB
random_21.txt AC 1206 ms 33848 KiB
random_22.txt AC 1182 ms 34108 KiB
random_23.txt AC 1303 ms 33824 KiB
random_24.txt AC 1199 ms 34824 KiB
random_25.txt AC 1213 ms 33840 KiB
random_26.txt AC 1176 ms 33992 KiB
random_27.txt AC 1185 ms 34144 KiB
random_28.txt AC 1202 ms 34028 KiB
random_29.txt AC 1200 ms 36344 KiB