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

C++ AC代码 724K 32MS

Posted by jacobkong at 2016-09-15 20:45:00 on Problem 1008
说一下容易忽略的地方:一个就是天数能被260整除的话,年份需要减一天,因为这一天还属于上一年的,不属于新的一年,另一个地方就是打印结果是,需要首先把Case 数打出来。。。太坑,我因为这个低级错误一直wa!!
代码:
#include <iostream>
#include <sstream>

using namespace std;
string Haab[19]={"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"};
string Tzolkin[20]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};

int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    cout<<n<<endl;
    while (n--) {
        int date, year;
        string month, fdate;
        cin>>fdate>>month>>year;
        for(int i=0; i<fdate.length(); i++){
            if(i==fdate.length()-1) fdate.erase(fdate.length()-1);
        }
        stringstream ss(fdate);
        ss>>date;
        int t_date, t_month, t_year;
        int month_num=0;
        for(int i=0; i<19; i++){
            if(month.compare(Haab[i])==0) month_num=i;
        }
        
        int day;
        day = year*365+month_num*20+date;
//        cout<<day<<endl;
        if((day+1)%260==0){
            t_year = (day+1)/260-1;
        }else{
            t_year=day/260;
        }
        
//        cout<<t_year<<endl;
        t_month = (day-t_year*260)%20;
        string t_month_str = Tzolkin[t_month];
        t_date = (day-t_year*260)%13+1;
        
        cout<<t_date<<" "<<t_month_str<<" "<<t_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