- Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
problem-collectingcollecting problemscollecting problems
Description
主题:
自动机
题目:
写一个DFA,使得其能识别二进制数字中3的倍数
(假定输入顺序是高位到低位)
(这个假定会让问题比较简单,但是低位到高位也能解决)
习题 还是 OT (在[]
中填入x
表示勾选):
- 习题
- OT
推荐理由:
将自动机中的“状态”与某些可以解释的东西联系在一起,增加对状态机的理解
题解:
状态机有3个状态,记作012.
状态i表示目前为止读到的数字串对应的二进制数字模3的余数。
那么状态转移就一目了然了
状态i接受输入j后,会转移到(2i+j)模3
状态 | 输入0 | 输入1 |
---|---|---|
0 | 0 | 1 |
1 | 2 | 0 |
2 | 1 | 2 |
参考资料:
UCB程序设计语言及编译器(CS164)课程作业1
其它:
Metadata
Metadata
Assignees
Labels
problem-collectingcollecting problemscollecting problems