-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEEDC Lab.py
More file actions
29 lines (28 loc) · 694 Bytes
/
EEDC Lab.py
File metadata and controls
29 lines (28 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
n = int(input())
a = list(map(int,input().split()))
tmp_sum = sum(a)
lucky = []
if n == 1:
lucky.append(1)
else:
for i in range(n):
if i == 0:
lucky.append(0)
else:
lucky.append(lucky[i-1])
#print(lucky)
if (tmp_sum - a[i])%3 == 0:
if i == 0:
if a[n-1] == 0:
lucky[i]+=1
elif i == n-1:
if a[n-2] == 0:
lucky[i]+=1
else:
if (a[i-1]+a[n-1])%10 == 0:
lucky[i]+=1
lucky.insert(0,0)
q = int(input())
for _ in range(q):
l,r = map(int,input().split())
print(lucky[r] - lucky[l-1])