1 条题解

  • 0
    @ 2025-2-14 20:50:07

    C++ :

    #include<iostream>
    #include<cstdlib>
    using namespace std;
    int a[15];
    int main()
    {
    	int poc=300;
    	int shou=0;
    	float cun=0;
    	float sum=0;
    	int z,yue;
    	for(int i=1;i<=12;i++)
    	  cin>>a[i];
    	for(int i=1;i<=12;i++)
    	{
    		shou=shou+poc;
    		if(shou-a[i]>=100)
    		{
    			cun=(shou-a[i])/100;
    			shou=(shou-a[i])%100;
    			sum=cun+sum;
    			continue;
    		}
    		if(shou-a[i]>=0&&shou-a[i]<100)
    		    shou=shou-a[i];
    		else
    			{
    				z=0;
    				yue=i;
    				break;
    			}
    	}
    	if(z==0)
    	  cout<<"-"<<yue;
    	else
    	  cout<<sum*120+shou;
    	//system("pause");
    	return 0;
    }
    
    

    Pascal :

    var
    a:array[1..1000]of longint;
    i,x,y:longint;
    s:real;
    begin
      for i:=1 to 12 do readln(a[i]);
      for i:=1 to 12 do
      begin
        x:=x+300-a[i];
        if x<0 then
        begin
          write('-',i);
          exit;
        end;
        y:=x div 100;
        if y>0 then s:=s+y*100;
        x:=x-y*100;
      end;
      s:=s+s*0.2+x;
      write(s:0:0);
    end.
    
    • 1

    信息

    ID
    425
    时间
    1000ms
    内存
    128MiB
    难度
    10
    标签
    递交数
    1
    已通过
    1
    上传者