1 solutions

  • 0
    @ 2025-11-5 20:08:34

    C :

    #include<stdio.h>
    int a[20];
    int main()
    {
    	int i,n,k,j,s=0;
        for(i=1;i<=12;i++)
        	scanf("%d",&a[i]);
        	n=0;
        for(i=1;i<=12;i++)
        {
        	n=n+300;k=n;
        	if(n-a[i]>=0) 
        	{
        	j=(k-a[i])/100;n=n-100*j;s=s+100*j;
        		}
        	else{ printf("-%d",i);j=0;break;}
        	n=n-a[i];j=1;
        }
    s=n+s*1.2;
    if(j)    printf("%d",s);
        return 0;
        }
    

    C++ :

    #include<iostream>
    #include<cstdio> 
    using namespace std;
    int main() 
    { 
       int j,a; 
     int n=0 , s=0 , m , i , leap =1; 
     for(j=0; j<12; j++) 
     { 
      scanf("%d" , &a); 
      n += 300 - a; 
      if( n < 0 && leap == 1) 
      { 
       i = j+1; 
       leap = 0; 
      } 
      m = n/100; 
      n -= m*100; 
      s += m*100; 
     } 
      
     if(leap == 1) 
     { 
      printf("%d\n" , n + (s*6)/5); 
     } 
     else 
     { 
      printf("-%d\n" , i); 
     } 
      
     
    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

    Information

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