Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- enum
- {
- BUF_SIZE = 1024,
- TABLE_OFFSET = 22,
- TABLES_COUNT = 1024,
- TABLE_SIZE = 4096
- };
- int
- main(void)
- {
- char buf[BUF_SIZE];
- int tables[TABLES_COUNT] = {0};
- int i;
- long long int sum = 0;
- unsigned int from, to;
- while (fgets(buf, BUF_SIZE, stdin) > 0) {
- sscanf(buf, "%x-%x", &from, &to);
- from >>= TABLE_OFFSET;
- to--;
- to >>= TABLE_OFFSET;
- for (i = from; i <= to; i++) {
- tables[i] = 1;
- }
- }
- for (i = 0; i < TABLES_COUNT; i++) {
- if (tables[i]) {
- sum += TABLE_SIZE;
- }
- }
- if (sum > 0) {
- sum += TABLE_SIZE;
- }
- printf("%lld\n", sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement