2012年8月20日

UVa 300 - Maya Calendar


#include <stdio.h>
#include <string.h>

char* M[20] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
int main() {
  int t, d, m, y;
  char tmp[30];
  scanf("%d\n", &t);
  printf("%d\n", t);
  while (t--) {
    scanf("%d. %s %d", &d, &tmp, &y);
    m = 0;
    if (!strcmp(tmp, "no"))
      m = 1;
    if (!strcmp(tmp, "zip"))
      m = 2;
    if (!strcmp(tmp, "zotz"))
      m = 3;
    if (!strcmp(tmp, "tzec"))
      m = 4;
    if (!strcmp(tmp, "xul"))
      m = 5;
    if (!strcmp(tmp, "yoxkin"))
      m = 6;
    if (!strcmp(tmp, "mol"))
      m = 7;
    if (!strcmp(tmp, "chen"))
      m = 8;
    if (!strcmp(tmp, "yax"))
      m = 9;
    if (!strcmp(tmp, "zac"))
      m = 10;
    if (!strcmp(tmp, "ceh"))
      m = 11;
    if (!strcmp(tmp, "mac"))
      m = 12;
    if (!strcmp(tmp, "kankin"))
      m = 13;
    if (!strcmp(tmp, "muan"))
      m = 14;
    if (!strcmp(tmp, "pax"))
      m = 15;
    if (!strcmp(tmp, "koyab"))
      m = 16;
    if (!strcmp(tmp, "cumhu"))
      m = 17;
    if (!strcmp(tmp, "uayet"))
      m = 18;
    int days = m * 20 + d + 1 + y * 365;
    m = days % 20 - 1;
    if (m == -1)
      m = 19;
    d = days % 13;
    if (!d)
      d = 13;
    y = days / 260 - !(days % 260);
    printf("%d %s %d\n", d, M[m], y);
  }
  return 0;
}

沒有留言:

張貼留言