版本比较
题解:P1001 A+B Problem
正文
增加 7 行删除 7 行
104 行未改动全部展开105106107108109109110111112113162 行未改动全部展开2762772782792802802812822832846 行未改动291292293294295295296297298299192 行未改动全部展开49249349449549649649749849950054 行未改动55555655755855955956056156256356456456556656756856957057057157257357436 行未改动104 行未改动全部展开 memory[ (code[i]>>56)&1 ? memory[p3] : p3 ] = val3; } else if(op==5) //Calculate (+ - * / %) { //想要乘方的建议自己写一个快速幂, 应该是能写的 //想要乘方的建议自己写一个快速幂, 应该是能写的 int p1 = (code[i]>>32)&65535, p2 = (code[i]>>16)&65535, p3 = code[i]&65535; int val1 = memory[ (code[i]>>58)&1 ? memory[p1] : p1 ], val2 = memory[ (code[i]>>57)&1 ? memory[p2] : p2 ], val3; int op2 = (code[i]>>52)&15;162 行未改动全部展开int memory[N],pos;string code[N]={
};string readStr(int x,int y) // 从 code[x][y] 开始读取一个字符串, 读到空格为止 string readStr(int x,int y) // 从 code[x][y] 开始读取一个字符串, 读到空格为止{ pos=y; string ret=""; int len=code[x].length();6 行未改动 ret=ret+code[x][pos++]; } return ret;}int readInt(int x,int y) // 从 code[x][y] 开始读取一个整数, 读到非数字为止 int readInt(int x,int y) // 从 code[x][y] 开始读取一个整数, 读到非数字为止{ pos=y; int ret=0, len=code[x].length(); bool f=0;192 行未改动全部展开- `output {mode} {x}`:以 `mode` 形式(`int` 或 `char`,其中 `char` 形式是按照 ASCII 码输出)输出内存的 $x$ 号位置中的数据。- `write {x} {y}`:将内存的 $x$ 号位置的数据设为 $y$。- `copy {x} {y}`:将内存的 $x$ 号位置的数据拷贝至内存的 $y$ 号位置。- `calc {mode} {x} {y} [z]`(当 `mode` 为 `not` 时无需 `z`):将内存的 $x$ 号位置的数据与内存的 $y$ 号位置的数据进行 `mode` 运算(`and`、`or`、`xor`、`add`、`sub`、`mul`、`div` 或 `mod`,其中 `div` 操作在除数为 $0$ 时会提示 `Error: Division by Zero` 并退出程序),并将结果存放在内存的 $z$ 号位置。
注:当 `mode` 为 `not` 时,其效果为将内存的 $x$ 号位置的数据按位取反的结果存放在内存的 $y$ 号位置;此处的 `and`、`or`、`xor` 和 `not` 均为位运算,逻辑运算是可以通过这个实现的,故没有单独制作。- `goto {x}`:跳转至第 $x$ 行(从 $0$ 开始)代码。- `if {mode} {x} {y} {z}`:如果内存的 $x,y$ 号位置的数据满足 `mode` 这一关系(`mode` 可在 `<`、`>`、`==`、`<=`、`>=` 和 `!=` 中选择),则跳转至第 $z$ 行(从 $0$ 开始)代码。- `++ {x}`:将内存的 $x$ 号位置的数据加 $1$。54 行未改动
P1226 【模板】快速幂(AC 记录:[link](https://www.luogu.com.cn/record/227743083)):
```cpp// 输入 & 预处理 // 输入 & 预处理"input 0", "input 1","input 2", "write 3 1","copy 0 4", "copy 1 5","write 7 1", "write 8 2",// 计算 // 计算"if == 5 6 17", "calc and 5 7 9","if == 9 6 13", "calc mul 3 4 3","calc mod 3 2 3", "calc div 5 8 5","calc mul 4 4 4", "calc mod 4 2 4","goto 8",// 输出 // 输出"output int 0", "write 10 94","output char 10", "output int 1","write 11 32", "output char 11","write 10 109", "output char 10",36 行未改动