5.2例题--细菌繁殖--2712

#include 
#include 
#include 

int main(int argc, char *argv[])
{
  int n, month1, day1, month2, day2, days, i;
  int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
  long bac1 ;
  
  scanf("%d",&n);
  while(n--)
  {
      scanf("%d %d %ld %d %d",&month1,&day1,&bac1,&month2,&day2);
      if( month1 == month2 ) days = day2 - day1 ;
      else
      {
          days = month[month1-1] - day1 ;
          for( i = month1+1 ; i < month2 ; i++ )
          {
               days += month[i-1];
          }
          days += day2 ;
      }
      
      printf("%ld\n",bac1*(long)pow(2,days));
  }
  
  system("PAUSE");	
  return 0;
}

你可能感兴趣的:(程序设计导引及在线实践)