#include <stdlib.h>
#include <stdio.h>
// State will be selected with probability proportional to its population
// Following table must be generated separately.
struct wtent {
struct {
char x[3];
} t[2];
double prob;
} WTable[] = {
"WY", "CA", 0.085625,
"VT", "CA", 1.094920,
"AK", "CA", 2.107520,
"ND", "CA", 3.114926,
"SD", "CA", 4.134775,
"DE", "CA", 5.151278,
"RI", "TX", 6.160671,
"MT", "TX", 7.166074,
"ME", "TX", 8.204617,
"NH", "TX", 9.205545,
"HI", "TX", 10.210396,
"WV", "FL", 11.259498,
"ID", "FL", 12.288035,
"NE", "FL", 13.290036,
"NM", "FL", 14.309973,
"CA", "NY", 15.401459,
"TX", "NY", 16.419179,
"MS", "NY", 17.430967,
"KS", "NY", 18.431093,
"AR", "NY", 19.449739,
"NY", "PA", 20.001637,
"FL", "PA", 21.462343,
"PA", "IL", 22.364202,
"NV", "IL", 23.468276,
"IA", "IL", 24.470157,
"IL", "OH", 25.142457,
"UT", "OH", 26.501050,
"OH", "GA", 27.371361,
"CT", "GA", 28.530289,
"OK", "GA", 29.594303,
"GA", "NC", 30.112871,
"OR", "NC", 31.620623,
"NC", "MI", 32.322010,
"KY", "MI", 33.663548,
"LA", "MI", 34.670525,
"MI", "NJ", 35.127576,
"AL", "NJ", 36.748917,
"SC", "NJ", 37.787779,
"NJ", "VA", 38.026338,
"MN", "VA", 39.841196,
"CO", "VA", 40.861675,
"VA", "WA", 41.006957,
"WI", "WA", 42.866564,
"WA", "AZ", 43.018913,
"MD", "AZ", 44.906044,
"AZ", "TN", 45.014414,
"TN", "IN", 46.059179,
"MO", "MA", 47.908375,
"IN", "MA", 48.065198,
};
#define SIZ (sizeof WTable / sizeof *WTable)
// Generate a standard uniform variate on (0,1)
#define UNIFSTD ((1 | random() & (1 << 30) - 1) / (double)(1 << 30))
int main(int argc, char **argv)
{
// default cnt is 0.1% total pop of 50 states
int cnt = argv[1] ? atoi(argv[1]) : 334236;
while (cnt--) {
double k = SIZ * UNIFSTD;
struct wtent *w = WTable + (int)k;
printf("%s\n", w->t[w->prob < k].x);
}
exit(0);
}