题目:

题解:
class Solution:
def rand10(self) -> int:
while True:
a = rand7()
b = rand7()
idx = (a - 1) * 7 + b
if idx <= 40:
return 1 + (idx - 1) % 10
a = idx - 40
b = rand7()
# get uniform dist from 1 - 63
idx = (a - 1) * 7 + b
if idx <= 60:
return 1 + (idx - 1) % 10
a = idx - 60
b = rand7()
# get uniform dist from 1 - 21
idx = (a - 1) * 7 + b
if idx <= 20:
return 1 + (idx - 1) % 10






![2024-10-10 问AI: [AI面试题]激活函数在神经网络中的作用是什么?](https://i-blog.csdnimg.cn/direct/9e8b38cba33f441ba4066aaac12569c8.png)












