Summiya14Fis14Samaa

TakeOff Mock Fall '21

Dec 2nd, 2021
719
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3.  
  4. int main(){
  5.     long unsigned int N =0, Q =0, i=0, j=0;
  6.     long unsigned int l =0, r =0;
  7.     long long unsigned sum = 0;
  8.     double avg = 0;
  9.     scanf("%lu %lu",&N, &Q);
  10.     int A[N];
  11.     for(i=0; i<N; i++){
  12.         scanf("%d",&A[i]);
  13.     }
  14.     for(i=0; i<Q; i++){
  15.         scanf("%lu %lu",&l, &r);
  16.        
  17.         for(j=l-1; j<r; j++){
  18.             sum += A[j];
  19.         }
  20.        
  21.         avg = (sum/(r-l));
  22.         printf("%.2lf\n",avg);
  23.         sum = 0; avg = 0;
  24.     }  
  25.     return 0;
  26. }
RAW Paste Data