Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct testCase {
- double rate;
- double balence;
- double payment;
- };
- //Function Prototypes
- void inputCases(testCase* myCases,int n);
- void outputResults(testCase* myCases,int n);
- int main() {
- int numOfCases;
- cin>>numOfCases;
- testCase* myCases=new testCase[numOfCases];
- inputCases(myCases,numOfCases);
- outputResults(myCases,numOfCases);
- return 0;
- }
- //Function Definitions
- void inputCases(testCase* myCases,int n) {
- for(int i=0; i < n; i++)
- cin>>myCases[i].rate>>myCases[i].balence>>myCases[i].payment;
- }
- void outputResults(testCase* myCases,int n) {
- for(int i=0; i < n; i++) {
- int numOfPayments=0;
- for(; myCases[i].balence > 0; myCases[i].balence-=myCases[i].payment) {
- if(numOfPayments > 1200) {
- cout<<"impossible"<<endl;
- break;
- }
- numOfPayments++;
- myCases[i].balence+=static_cast<double>(static_cast<int>((myCases[i].balence*(myCases[i].rate/100)+0.005)*100))/100;
- }
- if(numOfPayments <= 1200)
- cout<<numOfPayments<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement