【HDOJ】4541 Ten Googol

打表的大水题。

 1 /* 4541 */
 2 #include <cstdio>
 3 #include <cstdlib>
 4 #include <cstring>
 5 
 6 int a3[] = {1, 2, 6, 10};
 7 int a4[] = {0, 4, 5, 9};
 8 int a5[] = {3, 7, 8, 40, 50, 60};
 9 int a6[] = {11, 12, 20, 30, 80, 90};
10 int a7[] = {15, 16, 70};
11 int a8[] = {13, 14, 18, 19, 41, 42, 46, 51, 52, 56, 61, 62, 66};
12 int a9[] = {17, 21, 22, 26, 31, 32, 36, 44, 45, 49, 54, 55, 59, 64, 65, 69, 81, 82, 86, 91, 92, 96};
13 
14 
15 int main() {
16     int t, m, n;
17     int n3, n4, n5, n6, n7, n8, n9;
18     int i;
19     
20     #ifndef ONLINE_JUDGE
21         freopen("data.in", "r", stdin);
22         freopen("data.out", "w", stdout);
23     #endif
24     
25     n3 = sizeof(a3)/sizeof(int);
26     n4 = sizeof(a4)/sizeof(int);
27     n5 = sizeof(a5)/sizeof(int);
28     n6 = sizeof(a6)/sizeof(int);
29     n7 = sizeof(a7)/sizeof(int);
30     n8 = sizeof(a8)/sizeof(int);
31     n9 = sizeof(a9)/sizeof(int);
32     
33     scanf("%d", &t);
34     for (i=1; i<=t; ++i) {
35         scanf("%d %d", &n, &m);
36         printf("Case #%d: ", i);
37         --m;
38         if (n == 3) {
39             if (m >= n3)
40                 printf("-1\n");
41             else
42                 printf("%d\n", a3[m]);
43         }
44         if (n == 4) {
45             if (m >= n4)
46                 printf("-1\n");
47             else
48                 printf("%d\n", a4[m]);
49         }
50         if (n == 5) {
51             if (m >= n5)
52                 printf("-1\n");
53             else
54                 printf("%d\n", a5[m]);
55         }
56         if (n == 6) {
57             if (m >= n6)
58                 printf("-1\n");
59             else
60                 printf("%d\n", a6[m]);
61         }
62         if (n == 7) {
63             if (m >= n7)
64                 printf("-1\n");
65             else
66                 printf("%d\n", a7[m]);
67         }
68         if (n == 8) {
69             if (m >= n8)
70                 printf("-1\n");
71             else
72                 printf("%d\n", a8[m]);
73         }
74         if (n == 9) {
75             if (m < n9)
76                 printf("%d\n", a9[m]);
77             else if (m == n9)
78                 printf("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n");
79             else if (m == n9+1)
80                 printf("20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n");
81             else if (m == n9+2)
82                 printf("60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n");
83             else if (m == n9+3)
84                 printf("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n");
85             else
86                 printf("-1\n");
87         }
88     }
89     
90     return 0;
91 }

 

posted on 2014-12-24 16:58  Bombe  阅读(201)  评论(0编辑  收藏  举报

导航