Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么老是wr,是不是还有什么特别的数据啊?

Posted by TangMing at 2008-10-24 14:11:42 on Problem 2210
测试数据都可以过,只是仍然是wr~~
#include <iostream>
using namespace std;
int isleap(int y)
{
  if((y%4==0&&y%100!=0)||(y%400==0))
  return 1;
  return 0;	
}
int main()
{
    int n,j,i,total_day=0,s0,minute0,hour0,day0,month0,year0,totals0=0,t1;
    int s1,minute1,hour1,day1,month1,year1;
    int leap[2][12]={31,28,31,30,31,30,31,31,30,31,30,31,
    	             31,29,31,30,31,30,31,31,30,31,30,31,};
    int yearday[2]={365,366};
    int d[50002];
    double ret=1000.0/(36.0*24.0),x;
    for(i=2000;i<50002;i++)
    d[i]=isleap(i);
    cin>>n;
    while(n--)
    {
     scanf("%d:%d:%d %d.%d.%d",&hour0,&minute0,&s0,&day0,&month0,&year0); 
     for(i=2000;i<year0;i++)
      total_day+=yearday[d[i]];
     for(j=1;j<month0;j++)
      total_day+=leap[d[year0]][j-1];
     total_day+=day0-1;
     //cout<<total_day<<endl;
      //已经计算出总的天数
     year1=total_day/1000;
     total_day=total_day%1000;
     month1=total_day/100+1;
     day1=total_day%100+1;
     
     //printf("%d %d %d\n",day1,month1,year1);
     total_day=0;
    totals0=hour0*3600+minute0*60+s0;
    hour1=10*hour0/24;
    x=totals0*ret;
    t1=(int)x;
    t1=t1-hour1*10000;
    minute1=t1/100;
    s1=t1%100;
    printf("%d:%d:%d %d.%d.%d\n",hour1,minute1,s1,day1,month1,year1);
  
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator