HDU 1283 最简单的计算机
一道模拟水题
题解不写了
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; inline int read(){ int x=0,f=1,ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } char s[205]; int main(){ long long m1,m2,r1,r2,r3; while(scanf("%lld %lld",&m1,&m2)!=EOF){ scanf("%s",s);int len=strlen(s); r1=0,r2=0,r3=0; for(int i=0;i<len;i++){ if(s[i]=='A') r1=m1; if(s[i]=='B') r2=m2; if(s[i]=='C') m1=r3; if(s[i]=='D') m2=r3; if(s[i]=='E') r3=r1+r2; if(s[i]=='F') r3=r1-r2; } printf("%lld,%lld\n",m1,m2); } return 0; }