-
Notifications
You must be signed in to change notification settings - Fork 0
/
bai3.py
92 lines (81 loc) · 1.8 KB
/
bai3.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
n, m,mm = [int(x) for x in input().split()]
# print(mm)
a = list(map(int, input().split()))
sum=0
dem=0
for i in range(n):
# sum=0
for j in range(i):
# print(i,j)
sum=0
for k in range(j,i+1):
sum+=a[k]
# print(sum)
if((sum<=mm) & (sum>=m)):
dem+=1
for i in range(n):
if((a[i]<=mm) & (a[i]>=m)):
dem+=1
print(dem)
n, m,mm = [int(x) for x in input().split()]
# print(mm)
a = list(map(int, input().split()))
sum=0
dem=0
for i in range(n):
sum=0
for j in range(i,n):
# print(i,j)
# sum=0
sum+=a[j]
# print(sum)
if((sum<(mm+1)) & (sum> (m-1))):
dem+=1
# for i in range(n):
# if((a[i]<(mm+1)) & (a[i]> (m-1))):
# dem+=1
print(dem)
n, m,mm = [int(x) for x in input().split()]
# print(mm)
a = list(map(int, input().split()))
sum=0
dem=0
for i in range(n):
sum=0
for j in range(i,n):
# # print(i,j)
# sum=0
# for k in range(j,i+1):
# sum+=a[k]
# # print(sum)
sum+=a[j]
if((sum<=mm) & (sum>=m)):
dem+=1
# for i in range(n):
# if((a[i]<=mm) & (a[i]>=m)):
# dem+=1
print(dem)
n, m, M = input().split()
n = int(n)
m = int(m)
M = int(M)
arr = list(map(int, input().split()))
def check_subseq(sum_array):
if sum_array>=m and sum_array<=M:
return True
return False
def bound_subseq(arr):
sum_array = 0
count = 0
for i in range(n-1):
sum_array = arr[i]
if check_subseq(sum_array):
count += 1
for j in range(i+1, n):
sum_array += arr[j]
if check_subseq(sum_array):
count += 1
if check_subseq(arr[-1]):
count += 1
return count
print(bound_subseq(arr))