summaryrefslogtreecommitdiff
path: root/10114
diff options
context:
space:
mode:
Diffstat (limited to '10114')
-rw-r--r--10114/lonesome.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/10114/lonesome.cpp b/10114/lonesome.cpp
new file mode 100644
index 0000000..8c13b11
--- /dev/null
+++ b/10114/lonesome.cpp
@@ -0,0 +1,38 @@
+#include <iostream>
+using namespace std;
+
+int main()
+{
+ int dur;
+ cin>>dur;
+ while(dur>0)
+ {
+ int deprecs, months, depmonth, i;
+ double dwp, amt, val, cur_depval, iments, deps[100]={0.0};
+ bool nend;
+
+ cin>>dwp>>amt>>deprecs;
+ for(i=0;i<deprecs;i++)
+ cin>>depmonth>>deps[depmonth];
+
+ val = dwp+amt;
+ iments = amt/dur;
+ nend = true;
+
+ for(months=0; ; ++months)
+ {
+ if(deps[months]>0)
+ cur_depval=deps[months];
+ val -= val*cur_depval;
+ if(val>amt)
+ break;
+ amt -= iments;
+ }
+ if(months==1)
+ cout<<months<<" month\n";
+ else
+ cout<<months<<" months\n";
+ cin>>dur;
+ }
+ return 0;
+}