1 #include <bits/stdc++.h> 2 using namespace std; 3 long long n,x,t,m,k; 4 int main(){ 5 cin>>k; 6 while(k--){ 7 cin>>n>>x>>t; 8 m=min(t/x,n); 9 cout<<m*((n-m-1)+n)/2<<endl; 10 } 11 return 0; 12 }
1 #include <bits/stdc++.h> 2 using namespace std; 3 int n,q,l,r,i; 4 string s; 5 int main(){ 6 cin>>n>>q>>s; 7 vector<int>sum(n+1,0); 8 for(auto&c:s)sum[i+1]=sum[i]+c-'a'+1,i++; 9 while(q--){ 10 cin>>l>>r; 11 cout<<sum[r]-sum[l-1]<<endl; 12 } 13 return 0; 14 }