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 lxhgww at 2006-07-24 20:12:38 on Problem 2080
In Reply To:帮忙看一下这个代码,我测了很多组测试数据都过了.可还是WA.谢谢了! Posted by:lyq at 2006-07-24 10:43:58
#include<stdio.h>
int main()
{
	long day,d,c;
	int year;
	char s[10][20]={"Sunday" , "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" ,"Saturday"};
	scanf("%ld",&d);
	while (d!=-1)
	{
		day=d+1;
		c=(day-1)/146097;
		year=2000+c*400;
		day=(day-1)%146097+1;
		if (day>36525)
		{
			day=day-36525;
		    c=1+(day-1)/36524;
		    year=year+c*100;
		    day=(day-1)%36524+1;
		}
		else c=0;
		if (c==0)
		{
			c=(day-1)/1461;
		    year=year+c*4;
		    day=(day-1)%1461+1;
			c=-1;
		}
		else
		{
			if (day>1460)
			{
				c=1;
				day=day-1460;
			}
		    else c=0;
		    c=c+(day-1)/1461;
		    year=year+c*4;
		    day=(day-1)%1461+1;
		}
		if (c==0)
		{
		    c=(day-1)/365;
		    year=year+c;
		    day=(day-1)%365+1;
		}
		else
		if (day>366)
		{
			day=day-366;
		    c=1+(day-1)/365;
		    year=year+c;
		    day=(day-1)%365+1;
		}
		printf("%d-",year);
		if (day<=31) 
		{
			if (day>=10) printf("01-%d ",day);
		    else printf("01-0%d ",day);
		}
		  else
		  {
			  day=day-31;
			  if (year%4!=0||(year%100==0&&year%400!=0))
				  if (day<=28) 
				  {
					  if (day>=10) printf("02-%d ",day);
					    else printf("02-0%d ",day);
					  day=-1;
				  }
				  else day=day-28;
			  else 
			      if (day<=29)
				  {
				    if (day>=10) printf("02-%d ",day);
				    else printf("02-0%d ",day);
				    day=-1;
				  }
			      else day=day-29;
			  if (day!=-1)
			  {
				  if (day<=31) 
				  {
					  if (day>10) printf("03-%d ",day);
					    else printf("03-0%d ",day);
				  }
				    else
					{
						day=day-31;
						if (day<=30) 
						{
							if (day>=10) printf("04-%d ",day);
							else printf("04-0%d ",day);
						}
				         else
						 {
						    day=day-30;
							if (day<=31) 
							{
								if (day>=10) printf("05-%d ",day);
								  else printf("05-0%d ",day);
							}
				            else
							{
						       day=day-31;
							   if (day<=30) 
							   {
								   if (day>=10) printf("06-%d ",day);
								     else printf("06-0%d ",day);
							   }
				                else
								{
						          day=day-30;
								  if (day<=31) 
								  {
									  if (day>=10) printf("07-%d ",day);
									    else printf("07-0%d ",day);
								  }
				                     else
									 {
						                   day=day-31;
										   if (day<=31) 
										   {
											   if (day>=10) printf("08-%d ",day);
											   else printf("08-0%d ",day);
										   }
				                            else
											{
						                         day=day-31;
												 if (day<=30) 
												 {
													 if (day>=10) printf("09-%d ",day);
													 else printf("09-0%d ",day);
												 }
				                                  else
												  {
					                              	day=day-30;
													if (day<=31) 
													{
														if (day>=10) printf("10-%d ",day);
														else printf("10-0%d ",day);
													}
				                                        else
														{
					                                       	day=day-31;
															if (day<=30) 
															{
																if (day>=10) printf("11-%d ",day);
																else printf("11-0%d ",day);
															}
				                                            else 
															{
																if (day>=40) printf("12-%d ",day-30);
																  else printf("12-0%d ",day-30);
															}
														}
												  }
											}
									 }
								}
							}
						 }
					}
			  }
		  }
		  printf("%s\n",s[(d+6)%7]);
		  scanf("%ld",&d);
	}
	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