P1089 [NOIP2004 提高组] 津津的储蓄计划

在这里插入图片描述
在这里插入图片描述

#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    
    
    int n;
    int s=0,h=0;
    int k;
    int flog=0;

    for(int i=1; i<=12; i++)
    {
    
    
        cin>>n;
        flog=0;
        s=s+300-n;
        if(s<0)
        {
    
    
            k=i;
            flog=1;
            break;

        }

        h=h+s/100;
        s=s%100;
    }

    if(flog==1)
    {
    
    
        cout<<-k<<endl;
    }
    else
    {
    
    
        printf("%d\n",h*120+s);
    }

    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_45976312/article/details/112988384