Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- int a, b, n, tdig;
- unsigned long temp;
- int table[256] = {0, 1, 1, 2, 1, 2, 2, 3,
- 1, 2, 2, 3, 2, 3, 3, 4,
- 1, 2, 2, 3, 2, 3, 3, 4,
- 2, 3, 3, 4, 3, 4, 4, 5,
- 1, 2, 2, 3, 2, 3, 3, 4,
- 2, 3, 3, 4, 3, 4, 4, 5,
- 2, 3, 3, 4, 3, 4, 4, 5,
- 3, 4, 4, 5, 4, 5, 5, 6};
- std::cin >> n;
- while (n != 0)
- {
- std::cin >> a >> b;
- tdig = 0;
- for (int i = a; i <= b; i++)
- {
- temp = i;
- for (int j = 0; j < 6; j++)
- {
- tdig += table[temp & 63];
- temp >>= 6;
- }
- }
- std::cout << tdig << "\n";
- n--;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment