Niloy007

Aurna's Problem

Nov 18th, 2020
479
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int n;
  5.     scanf("%d", &n);
  6.     int arr[n], brr[n];
  7.     for (int i = 0; i < n; i++) {
  8.         scanf("%d", &arr[i]);
  9.     }
  10.  
  11.     int flag = 0, product = 1, size = 0;
  12.  
  13.     for (int i = 0; i < n; i++) {
  14.         if(flag == 3) {
  15.             flag = 0;
  16.             brr[size] = product;
  17.             size++;
  18.             printf("%d ", product);
  19.             product = 1;
  20.         }
  21.         product *= arr[i];
  22.         flag++;
  23.     }
  24.     printf("%d\n", product);
  25.     brr[size] = product;
  26.     size++;
  27.     double x;
  28.     for (int i = 0; i < size; i++) {
  29.         x += (1.0 / brr[i]);
  30.     }
  31.     printf("%lf\n", x);
  32. }
RAW Paste Data