T3000

Untitled

Nov 16th, 2021
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n,p,k,a,b,m,z;
  9.     long double x;
  10.     m=100;
  11.     cin>>n>>p>>k;
  12.     z=n;
  13.     cin>>a;
  14.     n-=1;
  15.     if(n==1)
  16.     {
  17.         b=k;
  18.     }
  19.     else
  20.     {
  21.         cin>>b;
  22.         n-=1;
  23.     }
  24.     while(n>0)
  25.     {
  26.         x+=(b-a)*((m+p)/100);
  27.           m+=p;
  28.         a=b;
  29.         cin>>b;
  30.  
  31.         n-=1;
  32.     }
  33.     if(z!=1){
  34.         x+=(k-b)*((m+p)/100);
  35.     }
  36.     cout<<fixed<< setprecision(4) <<x<<endl;
  37.  
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment