P1089题解 津津的储蓄计划

来水一篇题解

#include <iostream>
using namespace std;

int main()
{
    int month[12];
    int mother=0,have=0;
    for(int i=0;i<12;i++)
        cin>>month[i];//全部读入
    for(int i=0;i<12;i++)
    {
        have+=300;//得到了300元
        if(have<month[i])//如果不够这个月的
        {
            cout<<-1*(i+1);//输出月份
            return 0;//退出
        }
        have-=month[i];//减去这个月的
        mother+=have/100*100;//取走百位
        have=have%100;
    }
    cout<<mother*1.2+have;//妈妈手里的钱*120%加上自己有的
    return 0;
}

https://www.luogu.com.cn/problem/P1089

猜你喜欢

转载自www.cnblogs.com/include-blog/p/12365913.html