zeunig356 ho risolto numericamente il caso 3 (<<che ogni dialogo sia scelto da almeno uno studente>>) e ti confermo che l'esito è questo: P=0,99699
Il codice in linguaggio C:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
unsigned char f(unsigned char V[], unsigned char n);
int main(){
srand(time(0));
register unsigned int j;
register unsigned int cont=0;
unsigned char V[25];
clock_t start = clock();
for(j=0;j<100000000;j++){
if(f(V,25)==1){cont++;}
}
clock_t end = clock();
printf("P = %.8f\n",0.00000001*cont);
printf("%f s\n", (float)(end - start) / CLOCKS_PER_SEC);
return 0;
}
unsigned char f(unsigned char V[], unsigned char n){
unsigned char i,checker;
checker=0;
for(i=0;i<n;i++){
V[i]=rand()%(4); //0-1-2-3
}
for(i=0;i<n;i++){
if(V[i]==0){checker++;break;}
}
for(i=0;i<n;i++){
if(V[i]==1){checker++;break;}
}
for(i=0;i<n;i++){
if(V[i]==2){checker++;break;}
}
for(i=0;i<n;i++){
if(V[i]==3){checker++;break;}
}
if(checker==4){return 1;}else{return 0;}
}