/* TASK: cnums LANG: C */ /* precalculate 16 bits; sum both halves of word */ #include int count2[65536]; int bitcount(n) { int nones; for (nones = 0; n; n >>= 1) nones += n&1; return nones; } main () { FILE *fin = fopen("cnums.in", "r"); FILE *fout = fopen("cnums.out", "w"); int i, start, end, nrep=0, nones, n; for (i = 0; i < 65536; i++) /* make a 16-bit count matrix */ count2[i] = bitcount(i); fscanf (fin, "%d %d", &start, &end); for (i = start; i <= end; i++) if (count2[i&0xffff] + count2[i>>16] <= 4) nrep++; printf("%d\n", nrep); fprintf (fout, "%d\n", nrep); exit (0); }