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

帮忙看一下这个代码,我测了很多组测试数据都过了.可还是WA.谢谢了!

Posted by lyq at 2006-07-24 10:43:58 on Problem 2080
#include<fstream>
#include<algorithm>
#include<string>
#include<cmath>
#include<memory>
using namespace std;
ifstream cin("in.txt");
ofstream cout("out.txt");
int month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
string menu[7]={"Saturday","Sunday","Mondey","Tuesday","Wednesday","Thursday","Friday"};
int main()
{
	long int m,n,nmyear,nmmon,nmday,i;
	while(cin>>m&&m!=-1)
	{
		nmyear=2000;nmmon=0;nmday=0;
		n=m;
		while(true)
		{
			int flag=1;
			if(((nmyear%4==0&&nmyear%100!=0)||(nmyear%400==0))&&n>=366) {flag=0;nmyear++;n-=366;}
			else if(!((nmyear%4==0&&nmyear%100!=0)||(nmyear%400==0))&&n>=365) {flag=0;nmyear++;n-=365;}
			if(flag) break;
		}
		if(nmyear>=10000) continue;
 		if((nmyear%4==0&&nmyear%100!=0)||(nmyear%400==0)) month[1]=29;
		else month[1]=28;
		for(i=0;i<12;i++)
	    	if(n>=month[i]) {nmmon++;n-=month[i];}
			else break;
		nmday=n;
		cout<<nmyear<<'-';
		if(nmmon+1<10) cout<<'0'<<nmmon+1<<'-';
		else cout<<nmmon+1<<'-';
		if(nmday+1<10) cout<<'0'<<nmday+1<<' ';
		else cout<<nmday+1<<' ';
		cout<<menu[m%7+1-1]<<endl;
	}
	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