diff options
| author | Aditya Naik | 2018-05-10 00:15:29 -0400 |
|---|---|---|
| committer | Aditya Naik | 2018-05-10 00:15:29 -0400 |
| commit | 631ca6817d552db1725c7d6a445705f709302139 (patch) | |
| tree | 4ed1e943305fd5ff0772336034ee2a47458e68cc /10114 | |
| parent | 42fe0d8a06c1cecb7771823b9ae51220c469dc82 (diff) | |
reorg
Diffstat (limited to '10114')
| -rw-r--r-- | 10114/lonesome.cpp | 38 |
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; +} |
