Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- towns_amount = int(input())
- towns = list(map(int, input().split()))
- trees_amount = int(input())
- triangulars = [1]
- for index in range(2, len(towns)):
- triangulars.append((triangulars[-1] + index) % 998244353)
- for _ in range(trees_amount):
- start, end = map(int, input().split())
- start -= 1
- end -= 1
- length = (end - start + 1) // 2
- price = 0
- current = 0
- while start < end:
- price += triangulars[current] * towns[start]
- price %= 998244353
- price += triangulars[current] * towns[end]
- price %= 998244353
- current += 1
- start += 1
- end -= 1
- print(price)
Add Comment
Please, Sign In to add comment