同一天生日不知道哦那里错误了

问下各位我这个代码是哪里出了错误导致结果错误的,正确答案应该是20多人
问题是这个

img

img


#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int HaveSameBirthday(int stu[], int n) {
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
if (stu[i] == stu[j]) {
return 1;
}
}
}
return 0;
}

int main() {
srand(time(NULL));
int N = 10;
double prob = 0.0;
while (prob < 0.5) {
int count = 0;
for (int i = 0; i < 10000; i++) {
int stu[367] = {0};
for (int j = 0; j < N; j++) {
int birthday = rand() % 365 + 1;
stu[birthday]++;
}
if (HaveSameBirthday(stu, N)) {
count++;
}
}
prob = (double)count / 10000;
N++;
}
cout << "At least " << N << " students are needed for a probability of " << prob << " to have two students with the same birthday." << endl;
return 0;
}