标签:des style blog http color io os ar java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 163 Accepted Submission(s): 46
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <cmath> 6 #include <string> 7 #include <map> 8 #include <stack> 9 #include <vector> 10 #include <set> 11 #include <queue> 12 #pragma comment (linker,"/STACK:102400000,102400000") 13 #define maxn 1005 14 #define MAXN 2005 15 #define mod 1000000009 16 #define INF 0x3f3f3f3f 17 #define pi acos(-1.0) 18 #define eps 1e-6 19 typedef long long ll; 20 using namespace std; 21 22 char ope[6][5]={{"ADD"},{"SUB"},{"DIV"},{"MUL"},{"MOVE"},{"SET"}}; 23 char code[6][7]={{"000001"},{"000010"},{"000011"},{"000100"},{"000101"},{"000110"}}; 24 char co[31][6]={ {"00001"} , {"00010"} , {"00011"} , {"00100"} , {"00101"} , {"00110"} , {"00111"} , {"01000"} , {"01001"} , {"01010"} 25 , {"01011"} , {"01100"} , {"01101"} , {"01110"} , {"01111"} , {"10000"} , {"10001"} , {"10010"} , {"10011"} , {"10100"} 26 , {"10101"} , {"10110"} , {"10111"} , {"11000"} , {"11001"} , {"11010"} , {"11011"} , {"11100"} , {"11101"} , {"11110"} 27 , {"11111"}}; 28 char s1[5],s2[10]; 29 30 int OP(char str[]) 31 { 32 for (int i=0;i<6;i++) 33 { 34 if (strcmp(str,ope[i])==0) 35 return i; 36 } 37 } 38 39 int main() 40 { 41 int n; 42 while (~scanf("%d",&n)) 43 { 44 if (n==1) 45 { 46 scanf("%s%s",s1,s2); 47 int x=OP(s1); 48 int dd=x; 49 printf("%s",code[x]); 50 x=s2[1]-‘0‘; 51 int ok=0; 52 if (isdigit(s2[2])) 53 { 54 ok=1; 55 x=x*10; 56 x=x+s2[2]-‘0‘; 57 } 58 x--; 59 printf("%s",co[x]); 60 if (dd==5) 61 { 62 printf("00000\n"); 63 continue; 64 } 65 if (ok) 66 { 67 x=s2[5]-‘0‘; 68 if (isdigit(s2[6])) 69 { 70 x=x*10; 71 x=x+s2[6]-‘0‘; 72 } 73 } 74 else 75 { 76 x=s2[4]-‘0‘; 77 if (isdigit(s2[5])) 78 { 79 x=x*10; 80 x=x+s2[5]-‘0‘; 81 } 82 } 83 x--; 84 printf("%s\n",co[x]); 85 } 86 else if (n==0) 87 { 88 scanf("%s",s1); 89 int len=strlen(s1); 90 int t=1; 91 int sum=0; 92 for (int i=5;i>=0;i--) 93 { 94 int x=s1[i]-‘0‘; 95 sum+=t*x; 96 t=t*2; 97 } 98 if (sum>6||sum==0) 99 { 100 printf("Error!\n"); 101 continue; 102 } 103 sum--; 104 int o=sum; 105 int flag=sum; 106 // printf("%s",ope[sum]); 107 t=1; 108 sum=0; 109 for (int i=10;i>=6;i--) 110 { 111 int x=s1[i]-‘0‘; 112 sum+=t*x; 113 t=t*2; 114 } 115 if (sum>31||sum==0) 116 { 117 printf("Error!\n"); 118 continue; 119 } 120 int aa=sum; 121 // printf(" R%d",sum); 122 if (flag==5) 123 { 124 t=1; 125 sum=0; 126 for (int i=15;i>=11;i--) 127 { 128 int x=s1[i]-‘0‘; 129 // printf("x=%d\n",x); 130 sum+=t*x; 131 t=t*2; 132 } 133 if (sum==0) 134 { 135 printf("%s",ope[o]); 136 printf(" R%d",aa); 137 printf("\n"); 138 continue; 139 } 140 else 141 { 142 printf("Error!\n"); 143 continue; 144 } 145 } 146 t=1; 147 sum=0; 148 for (int i=15;i>=11;i--) 149 { 150 int x=s1[i]-‘0‘; 151 // printf("x=%d\n",x); 152 sum+=t*x; 153 t=t*2; 154 } 155 if (sum>31||sum==0) 156 { 157 printf("Error!\n"); 158 continue; 159 } 160 printf("%s",ope[o]); 161 printf(" R%d",aa); 162 printf(",R%d\n",sum); 163 } 164 } 165 return 0; 166 }
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/i8888/p/4051055.html