Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int n,p,k,a,b,m,z;
- long double x;
- m=100;
- cin>>n>>p>>k;
- z=n;
- cin>>a;
- n-=1;
- if(n==1)
- {
- b=k;
- }
- else
- {
- cin>>b;
- n-=1;
- }
- while(n>0)
- {
- x+=(b-a)*((m+p)/100);
- m+=p;
- a=b;
- cin>>b;
- n-=1;
- }
- if(z!=1){
- x+=(k-b)*((m+p)/100);
- }
- cout<<fixed<< setprecision(4) <<x<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment