题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4690
纯沙茶模拟题。。。
1 //STATUS:C++_AC_93MS_228KB 2 #include <functional> 3 #include <algorithm> 4 #include <iostream> 5 //#include <ext/rope> 6 #include <fstream> 7 #include <sstream> 8 #include <iomanip> 9 #include <numeric> 10 #include <cstring> 11 #include <cassert> 12 #include <cstdio> 13 #include <string> 14 #include <vector> 15 #include <bitset> 16 #include <queue> 17 #include <stack> 18 #include <cmath> 19 #include <ctime> 20 #include <list> 21 #include <set> 22 #include <map> 23 using namespace std; 24 //#pragma comment(linker,"/STACK:102400000,102400000") 25 //using namespace __gnu_cxx; 26 //define 27 #define pii pair<int,int> 28 #define mem(a,b) memset(a,b,sizeof(a)) 29 #define lson l,mid,rt<<1 30 #define rson mid+1,r,rt<<1|1 31 #define PI acos(-1.0) 32 //typedef 33 typedef __int64 LL; 34 typedef unsigned __int64 ULL; 35 //const 36 const int N=20; 37 const int INF=0x3f3f3f3f; 38 const int MOD=1000000007,STA=8000010; 39 const LL LNF=1LL<<60; 40 const double EPS=1e-8; 41 const double OO=1e15; 42 const int dx[4]={-1,0,1,0}; 43 const int dy[4]={0,1,0,-1}; 44 const int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 45 //Daily Use ... 46 inline int sign(double x){return (x>EPS)-(x<-EPS);} 47 template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;} 48 template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;} 49 template<class T> inline T lcm(T a,T b,T d){return a/d*b;} 50 template<class T> inline T Min(T a,T b){return a<b?a:b;} 51 template<class T> inline T Max(T a,T b){return a>b?a:b;} 52 template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);} 53 template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);} 54 template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));} 55 template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));} 56 //End 57 58 int hs[N][N]={ 59 {0,1,2,3,0,9,0,127,0,0,0,11,12,13,14,15}, 60 {16,17,18,19,0,0,8,0,24,25,0,0,28,29,30,31}, 61 {0,0,0,0,0,10,23,27,0,0,0,0,0,5,6,7}, 62 {0,0,22,0,0,0,0,4,0,0,0,0,20,21,0,26}, 63 {32,0,0,0,0,0,0,0,0,0,0,46,60,40,43,124}, 64 {38,0,0,0,0,0,0,0,0,0,33,36,42,41,59,0}, 65 {45,47,0,0,0,0,0,0,0,0,0,44,37,95,62,63}, 66 {0,0,0,0,0,0,0,0,0,96,58,35,64,39,61,34}, 67 {0,97,98,99,100,101,102,103,104,105,0,0,0,0,0,0}, 68 {0,106,107,108,109,110,111,112,113,114,0,0,0,0,0,0}, 69 {0,126,115,116,117,118,119,120,121,122,0,0,0,0,0,0}, 70 {94,0,0,0,0,0,0,0,0,0,91,93,0,0,0,0}, 71 {123,65,66,67,68,69,70,71,72,73,0,0,0,0,0,0}, 72 {125,74,75,76,77,78,79,80,81,82,0,0,0,0,0,0}, 73 {92,0,83,84,85,86,87,88,89,90,0,0,0,0,0,0}, 74 {48,49,50,51,52,53,54,55,56,57,0,0,0,0,0,0}, 75 }; 76 77 char ma[20]="0123456789ABCDEF"; 78 79 inline int getnum(char c) 80 { 81 return c<='9'?c-'0':c-'A'+10; 82 } 83 84 int main(){ 85 // freopen("in.txt","r",stdin); 86 // freopen("out.txt","w",stdout); 87 int i,j,x,y; 88 char c1,c2; 89 while((c1=getchar())!=' ') 90 { 91 c2=getchar(); 92 x=getnum(c1); 93 y=getnum(c2); 94 printf("%c%c",ma[hs[x][y]/16],ma[hs[x][y]%16]); 95 } 96 putchar(' '); 97 return 0; 98 } 99 100 /* 101 NUL SOH STX ETX . HT . DEL . . . VT FF CR SO SI 102 DLE DC1 DC2 DC3 . . BS . CAN EM . . IFS IGS IRS IUSITB 103 . . . . . LF ETB ESC . . . . . ENQ ACK BEL 104 . . SYN . . . . EOT . . . . DC4 NAK . SUB 105 SP . . . . . . . . . . . < ( + | 106 & . . . . . . . . . ! $ * ) ; . 107 - / . . . . . . . . . , % _ > ? 108 . . . . . . . . . ` : # @ ' = " 109 . a b c d e f g h i . . . . . . 110 . j k l m n o p q r . . . . . . 111 . ~ s t u v w x y z . . . . . . 112 ^ . . . . . . . . . [ ] . . . . 113 { A B C D E F G H I . . . . . . 114 } J K L M N O P Q R . . . . . . 115 . S T U V W X Y Z . . . . . . 116 0 1 2 3 4 5 6 7 8 9 . . . . . . 117 118 119 NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI 120 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC IFS IGS IRS IUSITB 121 SP ! " # $ % & ' ( ) * + , - . / 122 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 123 @ A B C D E F G H I J K L M N O 124 P Q R S T U V W X Y Z [ ] ^ _ 125 ` a b c d e f g h i j k l m n o 126 p q r s t u v w x y z { | } ~ DEL 127 128 for(i=0;i<16;i++){ 129 for(j=0;j<16;j++) 130 scanf("%s",E[i][j]); 131 } 132 for(i=0;i<8;i++){ 133 for(j=0;j<16;j++) 134 scanf("%s",A[i][j]); 135 } 136 mem(hs,0); 137 for(i=0;i<16;i++){ 138 for(j=0;j<16;j++){ 139 if(!strcmp(E[i][j],".") && (i!=4 || j!=11))continue; 140 for(int p=0;p<8;p++){ 141 for(int q=0;q<16;q++) 142 if(!strcmp(E[i][j],A[p][q])){ 143 hs[i][j]=p*16+q; 144 } 145 } 146 } 147 } 148 for(i=0;i<16;i++){ 149 printf("{%d",hs[i][0]); 150 for(j=1;j<16;j++){ 151 printf(",%d",hs[i][j]); 152 } 153 printf("}, "); 154 } 155 */