题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1283
100 288 ABECED 876356 321456 ABECAEDBECAF
388,388 2717080,1519268
代码如下:
#include <cstdio> #include <cstring> int main() { char s[217]; int M1, M2, R1, R2, R3; while(~scanf("%d%d",&M1,&M2)) { R1 = R2 = R3 = 0; scanf("%s",s); int len = strlen(s); for(int i = 0; i < len; i++) { if(s[i] == 'A') { R1 = M1; } else if(s[i] == 'B') { R2 = M2; } else if(s[i] == 'C') { M1 = R3; } else if(s[i] == 'D') { M2 = R3; } else if(s[i] == 'E') { R3 = R1 + R2; } else if(s[i] == 'F') { R3 = R1 - R2; } } printf("%d,%d\n",M1,M2); } return 0; }
原文地址:http://blog.csdn.net/u012860063/article/details/39084901