C-Masala

 

n=int(input())
a=map(int,input().split())
k,m=map(int,input().split())
if k>m:k,m=m,k
d=0
i=1
for j in a:
   if k<=i<=m:
       d+=j
   i+=1
print(d)

Rahimberganov Musobek yechimi.

 

n=int(input())
a=input().split()
k,m=map(int,input().split())
s=a[min(k,m)-1:max(k,m)]
print(sum(list(map(int,s))))

Shamsiddin Qutlimuratov yechimi

 

#include <iostream>
#include <vector>
#define ll long long
using namespace std;
int main(){
 ios::sync_with_stdio(0);
 cin.tie(0);
 ll n, sum=0, l, r;
 cin >>n;
 vector<ll> vc(n);
 for (ll &i:vc) cin >> i;
 cin >> l >> r;
 if (l>r) swap(l,r);
 for (int i=l-1; i<r; ++i) sum+=vc[i];
 cout << sum;
}

Maqsud Baxriddinov yechimi

 

E-masala

n=int(input())
a=map(int,input().split())
l,r=map(int,input().split())
k,m=map(int,input().split())
j=0
s=0
for i in a:
   if l<=j<=r:
       if i%k==m:
           s+=1
   j+=1
print(s)

Rahimberganov Musobek yechimi.
 

#include <bits/stdc++.h>
using namespace std;
int main() {
     ios::sync_with_stdio(false);
     cin.tie(nullptr);
     cout.tie(nullptr);
   int n, s = 0;
   cin >> n;
   vector<int> a(n);
   for (int &i : a) cin >> i;
   int l, r, k, m;
   cin >> l >> r >> k >> m;
   for (int i = l; i <= r; ++i) s += a[i] % k == m;
   cout << s;
   return 0;
}

Xaydaraliyev Jahonali yechimi