//array version
#include "Util/void.h"
#define rolldarg(arr) ({double r=rdouble();double res=0;\
for(size_t i=0; i<sizeof(arr)/sizeof(arr[0]);i++){r-=arr[i]*0.01;\
if(r<0.0){res=arr[i];break;}};res;})
int main(int argc,char**argv){
double chances[]={50.1,20.0,29.9};
printf("%.2f%% chance",rolldarg(chances) );
// ./roll 50.1 20.0 29.9
// 50.10% chance
;}