1 条题解

  • 0
    @ 2025-4-14 18:41:38

    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 :

    program save;
      var a:array[1..12]of integer;
          mother,jin,i:integer;
      begin
        jin:=0;
        mother:=0;
        for i:=1 to 12 do readln(a[i]);
        for i:=1 to 12 do
           begin
             jin:=jin+300;
             jin:=jin-a[i];
             if jin>=100 
               then  begin
                      mother:=mother+(jin div 100);
                      jin:=jin mod 100;
                     end
               else if jin<0
                      then begin
                           write('-',i);
                           halt;
                           end;
           end;
       mother:=mother*120;
       jin:=jin+mother;
       write(jin);
    end.
    
    • 1

    信息

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