1 条题解

  • 0
    @ 2025-9-10 0:06:25

    C++ :

    #include<iostream>
    using namespace std;
    int main()
    {
         int a[12],m=300,sheng=0,z,g=0,c=0,y;
         for(int i=1;i<=12;i++)
         {
         	cin>>a[i];
         	z=sheng+m;//月初总钱 
             
            if((z-a[i])>=0)
    		{
             c+=(z-a[i])/100*100;
             sheng=(z-a[i])-(z-a[i])/100*100;
             
            }
            if((z-a[i])<0)
            {
               cout<<-i<<endl;break;
            }
            if(i==12){
            
                      y=c+c/5+sheng;
                       cout<<y;break;
                    }
         }
        
         return 0;
    	
    }
    

    Pascal :

    var a:array[1..12]of integer;
        I,total,p:integer;
    begin
      {assign(input,'save.in');
      reset(input);
      assign(output, 'save.out');
      rewrite(output);}
      
      total:=0;
      for i:=1 to 12 do
    readln(a[i]);
      for i:=1 to 12 do
    begin
      total:=total+(300-a[i]);
      if total<0 then
        begin
          write('-',i);
           halt;
        end;
      if total>=100 then
        begin
          p:=p+total div 100;
          total:=total mod 100;
         end;
       end;
    writeln(p*120+total);
        {close(input);
        close(output);}
      end.
    
    • 1

    信息

    ID
    2626
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者