题目:

题解:
class Solution {
public:
int rand10() {
int a, b, idx;
while (true) {
a = rand7();
b = rand7();
idx = b + (a - 1) * 7;
if (idx <= 40) {
return 1 + (idx - 1) % 10;
}
a = idx - 40;
b = rand7();
// get uniform dist from 1 - 63
idx = b + (a - 1) * 7;
if (idx <= 60) {
return 1 + (idx - 1) % 10;
}
a = idx - 60;
b = rand7();
// get uniform dist from 1 - 21
idx = b + (a - 1) * 7;
if (idx <= 20) {
return 1 + (idx - 1) % 10;
}
}
}
};





![[含文档+PPT+源码等]精品基于Python实现的Django高校职业通的设计与实现](https://img-blog.csdnimg.cn/img_convert/ca01c18d3d9ab14b67492e0d5236092c.png)













