这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
题目地址:
http://acm.hdu.edu.cn/showproblem.php?pid=1283
水题,直接模拟就行:
// Tanky Woo
// HDOJ 1283
#include
using namespace std;
int M1, M2;
int R1, R2, R3;
char order[200];
int main()
{
while(scanf("%d %d", &M1;, &M2;) != EOF)
{
R1 = R2 = R3 = 0;
scanf("%s", order);
int len = strlen(order);
for(int i=0; i<len; ++i)
{
switch(order[i])
{
case 'A':
R1 = M1;
break;
case 'B':
R2 = M2;
break;
case 'C':
M1 = R3;
break;
case 'D':
M2 = R3;
break;
case 'E':
R3 = R1+R2;
break;
case 'F':
R3 = R1-R2;
}
}
printf("%d,%d\n", M1, M2);
}
return 0;
}