Hdoj's simplest computer
Simplest computer Time Limit: 2000/1000 ms (Java/Other) Memory Limit: 65536/32768 K (Java/Other) Total Submission (s): 40 Accepted Submission (s): 12 Font: times New Roman | Verdana | GeorgiaFont Size: Drawing → Problem Description a research organization named PigHeadThree designed a computer for experiment named PpMm. PpMm can only execute six simple commands A, B, C, D, E, F; only two memory M1, M2; three registers R1, R2, R3. The meaning of the six commands is as follows:
Command A: load the data of memory M1 to register R1;
Command B: load the data in memory M2 to register R2;
Command C: load the data in register R3 to memory M1;
Command D: load the data in register R3 to memory M2;
Command E: add the data in register R1 to the data in register R2. The result is put into Register R3;
Command F: subtract the data in register R1 from the data in register R2 and put the result in register R3.
Your task is to design a program to simulate PpMm running.
There are several groups of inputs. Each group has two rows. The first row is two integers, indicating the initial content in M1 and M2 respectively; the second line is A string of commands from uppercase letters A to F with A length not greater than 200. The meaning of the command string is described above. Output corresponds to the input of each group. The Output contains only one row and two integers, representing the content of M1 and M2 respectively. M1 and M2 are separated by commas.
Others: the initial values of R1, R2, and R3 are 0, and all intermediate results are between-2 ^ 31 and 2 ^ 31. Sample Input
100 288ABECED876356 321456ABECAEDBECAF
Sample Output
388,3882717080,1519268
#include
#include
char a[202];int main(){int m1,m2,i;while(~scanf(%d %d %s,&m1,&m2,a)){intr1=0,r2=0,r3=0; int len=strlen(a);for(i=0;i