#include<bits/stdc++.h>
using namespace std;
int main()
{
double downp, amtloan, car, b[105];
int i, c = 0, n, r, m;
while(cin >> n >> downp >> amtloan >> r && n > 0)
{
for(i=0;i<=n;i++)
b[i] = 0;
for(i=1;i<=r;i++)
{
cin >> m;
cin >> b[m];
}
c = 0;
car = downp + amtloan;
car = car - ((car*(b[0]*100.00))/100.00);
while(car <= amtloan && c <= n)
{
c++;
amtloan = amtloan - downp;
if(b[c] == 0)
b[c] = b[c-1];
car = car - ((car*(b[c]*100.00))/100.00);
}
if(c == 1)
cout << 1 << " month\n";
else
cout << c << " months\n";
}
return 0;
}
using namespace std;
int main()
{
double downp, amtloan, car, b[105];
int i, c = 0, n, r, m;
while(cin >> n >> downp >> amtloan >> r && n > 0)
{
for(i=0;i<=n;i++)
b[i] = 0;
for(i=1;i<=r;i++)
{
cin >> m;
cin >> b[m];
}
c = 0;
car = downp + amtloan;
car = car - ((car*(b[0]*100.00))/100.00);
while(car <= amtloan && c <= n)
{
c++;
amtloan = amtloan - downp;
if(b[c] == 0)
b[c] = b[c-1];
car = car - ((car*(b[c]*100.00))/100.00);
}
if(c == 1)
cout << 1 << " month\n";
else
cout << c << " months\n";
}
return 0;
}
Comments
Post a Comment