`

1008

阅读更多
总时间限制:
1000ms
内存限制:
65536kB
描述

During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, professor discovered that the Maya civilization used a 365 day long year, called Haab, which had 19 months. Each of the first 18 months was 20 days long, and the names of the months were pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu. Instead of having names, the days of the months were denoted by numbers starting from 0 to 19. The last month of Haab was called uayet and had 5 days denoted by numbers 0, 1, 2, 3, 4. The Maya believed that this month was unlucky, the court of justice was not in session, the trade stopped, people did not even sweep the floor. For religious purposes, the Maya used another calendar in which the year was called Tzolkin (holly year). The year was divided into thirteen periods, each 20 days long. Each day was denoted by a pair consisting of a number and the name of the day. They used 20 names: imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau and 13 numbers; both in cycles. Notice that each day has an unambiguous description. For example, at the beginning of the year the days were described as follows: 1 imix, 2 ik, 3 akbal, 4 kan, 5 chicchan, 6 cimi, 7 manik, 8 lamat, 9 muluk, 10 ok, 11 chuen, 12 eb, 13 ben, 1 ix, 2 mem, 3 cib, 4 caban, 5 eznab, 6 canac, 7 ahau, and again in the next period 8 imix, 9 ik, 10 akbal . . . Years (both Haab and Tzolkin) were denoted by numbers 0, 1, . . . , where the number 0 was the beginning of the world. Thus, the first day was: Haab: 0. pop 0 Tzolkin: 1 imix 0 Help professor M. A. Ya and write a program for him to convert the dates from the Haab calendar to the Tzolkin calendar.

输入
The date in Haab is given in the following format:
NumberOfTheDay. Month Year

The first line of the input file contains the number of the input dates in the file. The next n lines contain n dates in the Haab calendar format, each in separate line. The year is smaller then 5000.
输出
The date in Tzolkin should be in the following format:
Number NameOfTheDay Year

The first line of the output file contains the number of the output dates. In the next n lines, there are dates in the Tzolkin calendar format, in the order corresponding to the input dates.
样例输入
3
10. zac 0
0. pop 0
10. zac 1995
样例输出
3
3 chuen 0
1 imix 0
9 cimi 2801
 
翻译:略。
 
 
解决方案一: G++
 
#include <string.h>
#include <iostream>
using namespace std;

char Haab[19][10] = {"pop","no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh","mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"};
char Tzolkin[20][10] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
int type[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13};
int days = 0;

void calday(char* day);
void calmonth(char* month);
void calyear(int year);

int main()
{
    int n;
    cin>>n;
    cout<<n<<endl;
    while (n--)
    {
        days = 0;
        char day[10],month[10];
        int year;
        memset(day,0,10);
        memset(month,0,10);
        cin>>day>>month>>year;

        calday(day);
        calmonth(month);
        calyear(year);

        year = days/260;
        days %= 260;
        cout<<type[days%13];
        cout<<" ";
        cout<<Tzolkin[days%20];
        cout<<" ";
        cout<<year<<endl;
    }
    return 0;
}

void calday(char* day)
{
    int temp = *day-'0';
    while (*(++day)!='.')
    {
        temp = temp*10+*day-'0';
    }
    days += temp;
}

void calmonth(char* month)
{
    for (int i=0;i<19;i++)
    {
        if (strcmp(month,Haab[i])==0)
        {
            days += i*20;
            return;
        }
    }
}

void calyear(int year)
{
    days += year*365;
}
 
或者:
 
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std ;
void countMonth(char ch[],char Haab[][20],int *days);
void countDay(char k[],int *days);
void countYear(int l,int *days);
int main()
{

    char Haab[19][20]={"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol",
     "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab",
     "cumhu","uayet"} ;
    char Tzolkin[20][20]={"imix", "ik", "akbal", "kan", "chicchan",
     "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem",
      "cib", "caban", "eznab","canac", "ahau" } ;
    int a[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
    int n;
    cin>>n ;
    cout<<n<<endl;
    int l,days ;
    char ch[20] ,k[20];
    while(n--)
    {   days = 0 ;
        int *p=&days;
        cin>>k>>ch>>l ;
               countDay(k,p);
               countMonth(ch,Haab,p) ;
               countYear(l,p) ;
        int _days = 13*20 ;

        int year = days/_days ;
         days = days%_days ;
        int day = a[days%13] ;
        char month[20] ;
        strcpy(month,Tzolkin[days%20]) ;
        cout<<day<<" "<<month<<" "<<year<<endl ;
        }
    return 0 ;

}
void countDay(char k[], int *days)
{  int len = strlen(k);
   int i = 1 ;
  for(len=len-1;len>=0;len--)
  {   if(k[len]!='.'){
      *days += (k[len]-'0')*i ;
     // cout<<*days<<endl  ;
       i *= 10 ;
  }
  }
//cout<<*days<<endl  ;

}
void countMonth(char ch[],char Haab[][20],int *days)
{
for(int i=0;i<19;i++)
{
    if(strcmp(ch,Haab[i])==0)
    {
       *days += i*20 ;
    }

}

}
void countYear(int l,int *days)
{
     *days += l*365 ;

}
 突然发现我写的好复杂啊!有木有!
 
 
 
 
解决方案二: Java
     
package dsa;

import java.util.Scanner;
/**
 * 1008
 * @author tanlvxu
 *
 */
public class Demo10 {

static String Haab[] ={"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol",
		     "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab",
		     "cumhu","uayet"} ;
static String Tzolkin[]={"imix", "ik", "akbal", "kan", "chicchan",
	     "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem",
	      "cib", "caban", "eznab","canac", "ahau" } ;
static int type[] = {1,2,3,4,5,6,7,8,9,10,11,12,13} ;
static int days = 0 ;
	public static void main(String[] args) {
	  test() ;
	}
	public static void test()
	{

	     Scanner sc = new Scanner(System.in) ;
	     int n  = sc.nextInt() ;
	     System.out.println(n) ;
	     while(n>0)
	     {  
	    	 days = 0 ;
	    	 String day = sc.next() ;
	    	 String month = sc.next() ;
	    	 int year = sc.nextInt() ;
	    	 
	    	 calday(day);
	         calmonth(month);
	         calyear(year);
	    	 year = days/260 ;
	    	 days %= 260 ;
	    	 System.out.println(type[days%13]+" "+Tzolkin[days%20]
        +" "+year);
	    	 
	    	 
	    	 
	    	 n-- ;
	     }
	}
	/**
	 * 日转换为日
	 * @param day
	 */
	public static void calday(String day) 
	{     int j = 1 ;
		for(int i=day.length()-1;i>=0;i--)
		{ 
			if(day.charAt(i)!='.')
			{
				days += (day.charAt(i)-'0')*j ;
				j *= 10 ;
			}
			
		}

		
	}
	/**
	 * 月转化为日
	 * @param month
	 */
	public static void calmonth(String month)
	{
		for (int i=0;i<19;i++)
	    {
	        if (month.equals(Haab[i]))
	        {
	            days += i*20;
	            
	        }
	    }

	}
	/**
	 * 年转化为日
	 * @param year
	 */
	public static void calyear(int year)
	{
		days += year*365;

	}

}
 
 
分享到:
评论

相关推荐

    std1008-1987 IEEE 1008 单元测试国际标准1

    std1008-1987 IEEE 1008 单元测试国际标准概述 std1008-1987 IEEE 1008 单元测试国际标准是 American National Standard(ANSI),由 IEEE Standards Board 于 1986 年 12 月 11 日批准,并于 1993 年 12 月 2 日...

    HP1008系列打印机驱动

    HP1008系列打印机驱动是专为惠普(HP)1008型号打印机设计的一款重要软件组件,它的主要作用在于确保打印机与计算机之间的有效通信,从而使打印任务能够顺利执行。这款驱动程序兼容多种Windows操作系统,包括Windows...

    DGS1008A使用说明书

    DGS1008A网络设备说明书D-Link 绿色技术 D-Link 8 端口千兆简易桌面交换机是D-Link SOHO 设备的新成员,DGS-1008A 使用最新D-Link 绿色技术,在不影响产品性能的前提下,做到节 约能源、降低温度并提高产品最长使用...

    固网打印服务器HP1008MFP说明书.pdf

    HP-1008MFP固网打印服务器安装手册 一、安装“控制中心”程序 HP-1008MFP固网打印服务器安装手册中首先需要安装“控制中心”程序。 controls the entire print server system. 在安装过程中,需要确保Computer的IP...

    1ikdi9iwoIac_鸿达智控HD1008编程软件_

    标题 "1ikdi9iwoIac_鸿达智控HD1008编程软件_" 暗示了我们讨论的主题是关于鸿达智控公司的一款名为HD1008的编程软件,这款软件主要用于步进电机的调试。步进电机在自动化控制领域中广泛应用,如机器人、3D打印机、...

    HP-1008MFP打印服务器驱动

    HP-1008MFP是一款集打印、扫描、复印功能于一体的多功能激光打印机,而"HP-1008MFP打印服务器驱动"则是为了让该设备能与网络中的其他计算机无缝协作的关键软件。 首先,我们要理解什么是打印服务器。打印服务器是一...

    XM1008XM1009数据手册V1.051

    《XM1008/XM1009数据手册V1.051》是针对这两款微控制器的详细技术文档,提供了丰富的硬件设计和应用信息。以下将围绕标题和描述中的关键知识点进行深入解析: **1. 供电方案** 在微控制器的设计中,供电方案是至关...

    HP P1008打印机安装程序及驱动

    标题中的“HP P1008打印机安装程序及驱动”是指惠普(HP)P1008型号的打印机的安装软件和驱动程序。这款打印机是面向个人和小型办公室的一款入门级激光打印机,具备基本的打印功能,适用于文档打印需求。...

    AQ1008-2007《矿山救护规程》

    AQ1008-2007《矿山救护规程》 本标准是以《中华人民共和国安全生产法》、《中华人民共和国矿山安全法》、《煤矿安全规程》、《金属非金属矿山规程》等国家有关安全生产的法律、法规、规程和标准为依据制定的。标准的...

    hp1008打印机驱动下载 For XP/Vista/Win7.zip

    hp1008打印机驱动下载 For XP/Vista/Win7 设计类型:黑白激打 分 辨 率:600*600dpi 打印速度:16ppm 打印语言:HP PCL 5e 打印内存:标配内存:8MB ...惠普hp1008打印机是一款非常主流的打印机,因为它的耗材适应...

    hp1007 1008原版驱动 越南版驱动.rar

    标题中的“hp1007 1008原版驱动 越南版驱动.rar”指的是惠普(HP)1007和1008型号打印机的专用驱动程序,该版本是针对越南地区的。在IT领域,驱动程序是操作系统与硬件设备之间的重要桥梁,它允许操作系统识别并有效...

    HPLaserJet P1008打印机驱动

    【惠普LaserJet P1008打印机驱动】是一款专为惠普LaserJet P1008黑白激光打印机设计的重要软件组件,其主要功能是确保打印机与计算机之间的通信和数据传输,使得用户能够顺利地进行打印操作。驱动程序在计算机硬件与...

    xz1008a 流量计modbus说明书

    ### xz1008a 流量计 Modbus 说明书 #### 1. Modbus 协议介绍 ##### 1.1 协议简介 Modbus 是一种开放的通信协议,广泛应用于工业自动化领域,尤其适用于PLC(可编程逻辑控制器)之间的通信。它允许一台主设备(通常...

    TD-T 1008-2007 土地勘测定界规程

    《TD-T 1008-2007 土地勘测定界规程》是中华人民共和国国土资源行业标准,旨在规范土地勘测定界的工作流程和技术要求,确保土地使用范围的界定、界址位置的测定、土地利用现状的调绘以及用地面积的计算等工作的科学...

    港湾 uHammer1008Vy.zip

    标题“港湾 uHammer1008Vy.zip”似乎是指一个特定的软件或工具,可能与网络设备管理、故障诊断或性能优化有关。"uHammer"可能是该工具的品牌或系列名称,而"1008Vy"可能是型号或版本号。然而,由于没有提供详细的...

    惠普 P1008 驱动 win32

    标题中的“惠普 P1008 驱动 win32”指的是为惠普(HP)P1008型号打印机设计的适用于Windows 32位操作系统的驱动程序。这款驱动程序是确保打印机在32位Windows环境下正常运行所必需的软件组件。 ...

    TP-LINK TL-SF1008V产品手册

    TP-LINK TL-SF1008V是一款专为小型企业或家庭办公室设计的VLAN交换机,提供了8个10/100M自适应RJ45端口,适用于构建灵活、高效的局域网环境。这款交换机的主要特点和功能如下: 1. **VLAN支持**:TL-SF1008V支持无...

    HP1007 1008打印机驱动

    HP1007和HP1008是惠普公司推出的两款入门级激光打印机,主要面向个人用户和小型办公室。这两款打印机具有小巧的体积、经济的耗材以及较为简单的操作,深受用户喜爱。本文将深入探讨它们的驱动程序及其在安装与使用中...

    ASTM A1008.pdf

    这份标准的最新版本为A 1008/A 1008M - 05b,其中的"b"表示该版本在原版制定或修订后的最近一次修改。 标准的主要内容包括以下几个方面: 1. **范围**:ASTM A1008规范覆盖了冷轧碳钢、结构钢、高强度低合金钢以及...

    TP-LINK TL-SF1008D产品手册

    千兆远程智能交换机TL-SL2117+提供16个10/100M自适应RJ45端口,1个10/100/1000M自适应RJ45端口,支TL-SF1008D以太网交换机提供8个10/100Mbps自适应端口,高集成度桌面型设计,小巧、轻便,操作简单,适用于中小型...

Global site tag (gtag.js) - Google Analytics