Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<array>
- #include <bits/stdc++.h>
- #include<string>
- using namespace std;
- int main ()
- {
- int mon, nperiod,m,n=0;
- double down, loan,dp,dps[101],val,lperm;
- while(true){
- n=0;
- cin>>mon>>down>>loan>>nperiod;
- if(mon<0)
- break;
- for (int i=0;i<nperiod;i++){
- cin>>m>>dp;
- for(int j=m;j<101;j++)
- dps[j]=dp;
- }
- lperm=loan/mon;
- val=(loan+down);
- val-=val*dps[0];
- while(val<loan)
- {
- n++;
- loan-=lperm;
- val-=val*dps[n];
- }
- if(n==1)
- cout<<n<<" month"<<endl;
- else cout<<n<<" months"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement