标签:
Time Limit: 500/200 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 545 Accepted Submission(s): 267
#include<stdio.h> #include<string.h> #include <iostream> #include <algorithm> #include <stdlib.h> using namespace std; int a[10][30]={ {-1}, {-1}, {-1}, {-1,1,2,6,10}, {-1,0,4,5,9}, {-1,3,7,8,40,50,60}, {-1,11,12,20,30,80,90}, {-1,15,16,70}, {-1,13,14,18,19,41,42,46,51,52,56,61,62,66}, {-1,17,21,22,26,31,32,36,44,45,49,54,55,59,64,65,69,81,82,86,91,92,96} }; char str[5][200] ={"0", "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }; int main() { int tcase; scanf("%d",&tcase); int t = 1; while(tcase--){ int k,b; scanf("%d%d",&k,&b); printf("Case #%d: ",t++); if(k==3){ if(b>4) printf("-1\n"); else printf("%d\n",a[k][b]); } if(k==4){ if(b>4) printf("-1\n"); else printf("%d\n",a[k][b]); } if(k==5){ if(b>6) printf("-1\n"); else printf("%d\n",a[k][b]); } if(k==6){ if(b>6) printf("-1\n"); else printf("%d\n",a[k][b]); } if(k==7){ if(b>3) printf("-1\n"); else printf("%d\n",a[k][b]); } if(k==8){ if(b>13) printf("-1\n"); else printf("%d\n",a[k][b]); } if(k==9){ if(b>26) printf("-1\n"); else if(b>22) printf("%s\n",str[b-22]); else printf("%d\n",a[k][b]); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5626127.html