Posted on 2009-06-05 10:24
Hero 阅读(105)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 //1229 Accepted 15 192 1961 C++
2
3 //巨无聊的一道题目,WA了一天
4
5 #include <iostream>
6 #include <string>
7 #include <algorithm>
8 using namespace std ;
9
10 const int size = 2000 ;
11
12 int tnum ;
13 int inn ;
14
15 const int sny = 2008 ;
16 const int snm = 10 ;
17 const int snd = 5 ;
18 //12 1 2 3 4 5 6 7 8 9 10 11 12
19 const int mday[15] = {31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } ;
20 //const int mday[15] = {28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28 } ;
21 int y, m, d ;
22
23 int main()
24 {
25 //freopen( "in.txt", "r", stdin ) ;
26 //freopen( "out.txt", "w", stdout ) ;
27
28 while( cin >> tnum )
29 //cin >> tnum ;
30 {
31 while( tnum -- )
32 {
33 char ch ;
34 scanf( "%d", &y ) ;
35 if( y > 2009 ) while(1) ;
36
37 while( (ch=getchar()) != '.' ) ;
38 m = 0 ;
39 ch = getchar() ;
40 m += (ch-'0')*10 ;
41 ch = getchar() ;
42 m += (ch-'0') ;
43
44 while( (ch=getchar()) != '.' ) ;
45 d = 0 ;
46 ch = getchar() ;
47 d += (ch-'0')*10 ;
48 ch = getchar() ;
49 d += (ch-'0') ;
50
51 int ty = y ;
52 int tm = m ;
53 int td = d ;
54
55 //int mon = ((m+12)-10)%12 + 1 ;
56 //if( y > 2008 ) mon = m + 3 ;
57 //else mon = m - 10 + 1 ;
58
59 int day = 0 ;
60 if( m < 10 ) m = m + 12 ;
61 for( int i=10; i< m; i++ )
62 {
63 day += mday[i%12] ;
64 }
65 day += d-5 ;
66
67 int mon = day / 28 + 1 ;
68 /*
69 day = 0 ;
70 if( y == 2008 )
71 {
72 for( int i=10; i<m; i++ )
73 {
74 day += mday[i] ;
75 }
76 }
77 else
78 {
79 for( int i=10; i<=12; i++ )
80 {
81 day += mday[i] ;
82 }
83 for( int i=1; i<m; i++ )
84 {
85 day += mday[i] ;
86 }
87 }
88 day += d-5 ;
89 */
90 int week = day / 7 + 1 ;
91
92 //printf( "%d.%d.%d ", ty, tm, td ) ;
93 printf( "%d %d\n", week, mon ) ;
94 }
95 }
96
97 return 0 ;
98 }