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

为什么总是错,测试都是对的,求指导

Posted by lsjseu at 2013-01-20 22:32:53 on Problem 1008
#include <iostream>
#include <map>
#include <string>
#include <cstdio>


using namespace std;


const string HaabYear[19]={"pop", "no", "zip","zotz", "tzec", 
"xul", "yoxkin", "mol", "chen", "yax",
"zac", "ceh", "mac", "kankin", "muan",
"pax", "koyab", "cumhu","uayet"};

const string Tzolkin[20]={"imix", "ik", "akbal", "kan", "chicchan", 
"cimi", "manik", "lamat", "muluk", 
"ok", "chuen", "eb", "ben", "ix", 
"mem", "cib", "caban", "eznab", "canac","canac"};

map<string,int> HaabYearMap;
void Init()
{
	int i;
	for(i=0;i<19;i++){
		HaabYearMap.insert(make_pair(HaabYear[i],i+1));
	}
}

int Haab(const string& str,const string &month,int year)
{
	int i=0;
	int day = 0;
	int ret;
	string tmp;
	while(str[i]>='0'&&str[i]<='9'){
		day = day*10+str[i]-'0';
		i++;
	}
	ret = year*365+(HaabYearMap[month]-1)*20+day+1;
	return ret;
}

void Haab2Tzolkin(const string& str,const string &month,int year)
{
	int day = Haab(str,month,year);
	int rem = day%260;
	cout<<rem%13<<" ";
	cout<<Tzolkin[rem%20-1]<<" ";
	cout<<day/260<<endl;
}


int main()
{
	Init();
	int n,i=0;
	cin>>n;
	while(n--){
		string day,month;
		int year;
		cin>>day>>month;
		cin>>year;
		Haab2Tzolkin(day,month,year);
	}
	system("pause");
	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