标题: 一道简单的ACM题,不过做了很久不知道为什么会是wrong answer,跪求解释啊 [打印本页] 作者: Hundred 时间: 2014-2-19 18:00 标题: 一道简单的ACM题,不过做了很久不知道为什么会是wrong answer,跪求解释啊 [size=+2]Maya Calendar ' [2 _" S" b5 r$ e# v; A. ?; Y$ F" c
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. 3 Q6 F- [4 h2 n; i$ I$ s
Notice that each day has an unambiguous description. For example, at the beginning of the year the days were described as follows: 1 h" ^3 D/ j& C3 w1 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 . . .5 b" |; {! _7 Z/ [4 |
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: - A5 U. }! \" z
Haab: 0. pop 09 m; e4 h- U* n2 b* D2 H
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. ! f8 k ~! E# }7 O9 n! VInputThe date in Haab is given in the following format:NumberOfTheDay. Month Year / c2 q$ R9 }! J1 l1 p% X. j- tThe first line of the input contains the number of the input dates in the input. The next n lines contain n dates in the Haab calendar format, each in separate line. The year is smaller then 5000. 0 F8 w& G! d2 ]) R" R- W, h, o OutputThe date in Tzolkin should be in the following format:Number NameOfTheDay Year' P$ f9 {& Z* ]8 m, V
The first line of the output 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. 4 k q* H% E4 g0 B2 m4 T! Z+ d6 `( w6 {- x6 |- R Sample Input310. zac 00. pop 010. zac 1995Sample Output33 chuen 01 imix 09 cimi 2801. S4 T L5 ]+ w5 ~
) s/ M2 w" B1 L; X
下面是我的代码,虽然繁琐点5 c5 S# j, n5 U& v5 n
#include <stdio.h> 1 d0 Y- W+ E- f1 x/ @3 R#include <string.h>5 w1 ]5 @4 r' R% y/ n5 N- [
void main(), ^; W6 ~8 O( I) d' o) ~
{ 1 ]- y/ B8 r1 W* y$ M3 j int n;//用于记数! G2 \4 q' ]6 j1 f+ }: G
scanf("%d",&n);9 I0 ?7 }* O- ~
printf("%d\n",n); " W# _3 J9 ? b U' z6 ]! T, f" Q% Z+ h9 i7 J7 J
while(n--) S, J3 H' ?, Q {$ w6 i' D. ~4 q! P _& Z8 O! ?
//定义Haab 的年月日5 C3 O, f' s0 T9 r4 C0 Y* e# a: _
int day,year; * H4 J8 ^) C$ D( u' h2 a2 k! u. T3 } char month[10]; 2 W# ^" \9 d& L5 z8 G5 j6 S. | //总共天数3 O/ T( V9 R, g
int number;8 B) C. Y* v" L
6 y! C/ O2 I! g* [ I$ p( h
int i=0;8 I5 K f0 i2 m5 G
* W9 K# T4 P, o //接收到Haab 的年月日 9 |/ N- e5 \1 R scanf("%d",&day); 4 [' M6 u# [1 N- ^: L' b
while(1) + f/ [0 T5 H- S3 M1 Y. ]3 W7 _) l { % E( h+ o0 e# D1 E' J$ E scanf("%c",&month);6 c: {3 d. E/ e* j! Z
if (month>=97&&month<=122) l- {- M7 z2 t g4 _8 t# X
break;& w5 `4 ^2 m9 ?; G& l6 _0 x; _
} # m0 Y8 o6 h8 P# Q! ?! ]( ^$ I+ v3 Q while(month>=97&&month<=122) / S6 z- r# h, D { + d+ ?. E$ I: c: ~3 G i++; 5 `9 {% k) V1 t8 r+ h scanf("%c",&month); 3 X6 O6 ]5 u) t% b0 F( f) c; U% v }/ _4 L; T9 j; w
scanf("%d",&year);" U. s) K; i' ^6 ~
+ p, C) s) x0 ] //方便后面的比较 4 y+ a2 w* G0 S; ~; P4 l+ L for(i=0;i<10;i++) % `6 E9 W' f' B- t% C, m/ Q) o { 9 g& ^4 c& j' M$ F9 [: {& S if(month<97||month>122)3 U( i7 O N7 d. z/ \
{ / a( B! y0 K& p& j0 E: r month='\0'; ; v8 x2 m B5 ?" T* l i++;; P# ?/ ]3 Y) _2 }
}- c4 G% `6 z3 i% `- }& A7 V3 H
}0 ?6 E1 l. q) Z: S: l* U