题解:P1089 [NOIP 2004 提高组] 津津的储蓄计划
chillchill · · 题解
博客园食用通道
题目思路
其实就是循环处理每个月,计算钱是每个月减去要花加上给的
如果没有中途跳出则输出剩下的加上存的钱乘
AC 代码
AC 记录
#include <iostream>
using namespace std;
int main()
{
int money=0,save=0;
for (int i=1;i<=12;i++)
{
int use;
cin >> use;
money=money+300-use; // 这个月的钱
if (money<0) // 如果钱<0,则结束
{
cout << "-" << i << "\n";
return 0;
}
save+=money/100*100; // 存入整百
money%=100;
}
cout << money+1.0*save*1.2;
return 0;
}
写在最后
这是我的第一篇能上交的题解,能点赞一下吗