1074:津津的儲蓄計劃-信息學奧賽一本通
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
const double credit=300;//媽媽每個月發(fā)的零用錢
double cash=0;//津津手里的現(xiàn)金?
double deposit;//津津存在媽媽那里的錢,只能是整百
for(int X=1;X<=12;X++){
double budget;//預算
cin>>budget;
cash+=credit;//300零用錢入賬?
cash-=budget;//現(xiàn)金-預算?
if(cash<0){
cout<<-X;
return 0;//直接輸出并結(jié)束程序?
}
if(cash>=100){
int hundred=(int)cash/100*100;
deposit+=hundred;
cash-=hundred;
}
}?
printf("%.0lf",deposit*1.2+cash);
return 0;
}
標簽:信息學奧賽一本通