1
A
回答
0
鉴于像B111 ... 10111 ... ... 1BBB,输入其中的1的第一字符串是(即,1^A)的一元编码和所述第二串1s是b的一元编码(即1^b),我们可以设计一个单带确定性图灵机来计算一个mod b(通过在留下磁带上留下的一个mod b的一元表示后进入暂停接受) 。
首先注意一个mod b < a,所以我们可以通过从a的一元表示中删除一些1,并从b的一元表示中删除所有的1来恢复mod b的一元表示。注意到mod b =(a - b)mod b,至少当a> = b;当一个< b,那么一个mod b = a。这个观察结果表明,我们可以从a的一元表示中删除b 1,直到剩余的b 1少于b 1,此时我们从b的表示中删除1,并停止接受。
伪代码:
move right until you find a blank.
move one step to the left.
you are now looking at the last 1 in b's representation.
mark this as Y and move left until you find 0.
move left until you find a 1 or blank.
you are now looking at the last 1 in a's representation, or blank.
if 1, mark this as X and move right until you find Y.
if blank, a < b; change all Xs to 1s and all 0s, 1s and YBs to blanks. halt-accept.
move one step to the left.
you are now looking at the last 1 in b's representation, or 0.
if 1, continue as above.
if 0, b < a; change all Xs to 0s, all Ys to 1s, and restart from the beginning
举例:10 MOD 3
B11111111110111BBB...
^
B11111111110111BBB...
^ move right until you find a blank
B11111111110111BBB...
^ move one step to the left. looking at last 1 in b
B1111111111011YBBB...
^ mark as Y and move left to 0
B1111111111011YBBB...
^ move one step to the left. looking at last 1 in a.
B111111111X011YBBB...
^ mark as X and move right to Y
B111111111X011YBBB...
^ move one step to the left. looking at last 1 in b.
B111111111X01YYBBB...
^ mark as Y and move left to 0
B111111111X01YYBBB...
^ move left to 1
B11111111XX01YYBBB...
^ mark as X and move right to Y
B11111111XX01YYBBB...
^ move one step to the left. looking at last 1 in b
B11111111XX0YYYBBB...
^ mark as Y and move left to 0
B11111111XX0YYYBBB...
^ move left to 1
B1111111XXX0YYYBBB... mark as X and move right to Y
^
B1111111XXX0YYYBBB... move one step left. looking at 0; b < a
^
B11111110000111BBB...
^ change Xs to 0s and Ys to 1s; start over.
(above process repeats two more times)
B10000000000111BBB...
^ erased 3x 1s from a 3x times
B10000000000111BBB...
^ move right to blank
B10000000000111BBB...
^ move one step left. looking at last 1 in b
B1000000000011YBBB...
^ mark as Y and move left to 0.
B1000000000011YBBB...
^ move left to 1
BX000000000011YBBB...
^ mark as X and move right to Y
BX000000000011YBBB...
^ move one step left. looking at last 1 in b.
BX00000000001YYBBB...
^ mark as Y and move left to 0
BX00000000001YYBBB...
^ move left to blank. a < b.
B1BBBBBBBBBBBBBBBB...
^ change Xs to 1s and 0s, 1s, Ys to blank. halt-accept
相关问题
- 1. (a/b)mod n为大数?
- 2. 图灵机MOD功能
- 3. 图灵机:取两个数字的mod?
- 4. (a mod 2 * x) - (a mod x)
- 5. python a = b b = c函数ETC
- 6. 上图灵机
- 7. 使deepEquals(a,b)函数无===
- 8. 输入(a + b)** 2,输出a * a + a * b + b * a + b * b
- 9. 说到函数依赖时,A→B与B→A是否相同?
- 10. PHP函数,将'a,b'转换为'a','b''
- 11. 函数f(a b)= b(a)有一个共同的名字吗?
- 12. Python a,b = b,a + b
- 13. 测试非整数是否在范围[a,b) - 或[a,b],(a,b),(a,b)
- 14. 将函数a中创建的变量传递给函数b当函数b位于函数a中时
- 15. 从{a-b,b-c,c-a}改变为{(a,b),(b,c),(c,a)}?
- 16. 混合两个矢量:[a a]和[b b] to [a b a b]
- 17. 类型参数(F:((A,B))⇒B)(隐式CMP:订货[B]):(A,B)
- 18. 设计图灵机
- 19. A模B,A和B是非常大的数字
- 20. 从视图中调用视图B中的jQuery函数A
- 21. 函数A调用调用函数A的函数B,你称之为什么?
- 22. A→B,B→A类协会
- 23. (A && B)与(A和B)
- 24. GROUP BY(A,B)和(B,A)
- 25. jquery函数(a,b)需要说明
- 26. 函数(a,b)的值是什么?
- 27. PHP变换阵列'a','b','c'到'a/b/c','a/b','a'
- 28. 如何写一个函数A调用函数B,函数B调用函数A没有完成函数A,无限循环呢?
- 29. C++:a-power b模数k
- 30. 功能找到a^b的余数,其中a,b是正整数
太好了!谢谢! – simone