1 solutions

  • 0
    @ 2025-11-5 16:37:40

    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

    Information

    ID
    17884
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By