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,第二个AC?我觉得一样的啊!

Posted by hakky at 2008-11-11 12:08:13 on Problem 1008
第一个:
#include"iostream"
#include"string"
using namespace std;
int month(string m){
	    string mm[20]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen",
			"yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu"};
	    if(m==mm[0])return 1;
	    if(m==mm[1])return 2;
		if(m==mm[2])return 3;
		if(m==mm[3])return 4;
		if(m==mm[4])return 5;
		if(m==mm[5])return 6;
		if(m==mm[6])return 7;
		if(m==mm[7])return 8;
		if(m==mm[8])return 9;
		if(m==mm[9])return 10;
		if(m==mm[10])return 11;
		if(m==mm[11])return 12;
		if(m==mm[12])return 13;
		if(m==mm[13])return 14;
		if(m==mm[14])return 15;
		if(m==mm[15])return 16;
		if(m==mm[16])return 17;
		if(m==mm[17])return 18;
}
int main(){
    int n;
	cin>>n;
	cout<<n<<endl;
	int k;
	for(k=0;k<n;k++){
		int day;
		cin>>day;
		getchar();
		string mon;
		cin>>mon;
		int year;
		cin>>year;
		int days;
		if(mon=="uayet")
			days=year*365+360+day+1;//下面的没加1
		else
			days=year*365+20*(month(mon)-1)+day+1;
		string mm[20]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", 
			"muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
		year=days/260;
		days=days%260;
		if(year%365==0&&year!=0)
			year--;
		int num;
		num=days%20;
		if(num==0)
			num=20;
		day=days%13;
		if(day==0)
			day=13;
		cout<<day<<" "<<mm[num-1]<<" "<<year<<endl;
	}
	return 0;
}
第二个:
#include"iostream"
#include"string"
using namespace std;
int month(string m){
	    string mm[20]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen",
			"yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu"};
	    if(m==mm[0])return 1;
	    if(m==mm[1])return 2;
		if(m==mm[2])return 3;
		if(m==mm[3])return 4;
		if(m==mm[4])return 5;
		if(m==mm[5])return 6;
		if(m==mm[6])return 7;
		if(m==mm[7])return 8;
		if(m==mm[8])return 9;
		if(m==mm[9])return 10;
		if(m==mm[10])return 11;
		if(m==mm[11])return 12;
		if(m==mm[12])return 13;
		if(m==mm[13])return 14;
		if(m==mm[14])return 15;
		if(m==mm[15])return 16;
		if(m==mm[16])return 17;
		if(m==mm[17])return 18;
}
int main(){
    int n;
	cin>>n;
	cout<<n<<endl;
	int k;
	for(k=0;k<n;k++){
		int day;
		cin>>day;
		getchar();
		string mon;
		cin>>mon;
		int year;
		cin>>year;
		int days;
		if(mon=="uayet")
			days=year*365+360+day;
		else
			days=year*365+20*(month(mon)-1)+day;
		string mm[20]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", 
			"muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
		year=days/260;
		days=days-year*260;
		int num;
		num=days%20;
		day=days%13+1;
		cout<<day<<" "<<mm[num]<<" "<<year<<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