Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool IsGood(uint64_t num) {
- char last_digit = '0' + (num % 2);
- num /= 2;
- int cnt = 1;
- while (num > 0)
- {
- char digit = '0' + (num % 2);
- num /= 2;
- if (last_digit != digit) {
- cnt++;
- last_digit = digit;
- }
- if (cnt > 3) {
- return false;
- }
- }
- return cnt == 3;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- uint64_t from;
- uint64_t to;
- cin >> from >> to;
- uint64_t grow_days_cnt = 0;
- while (from <= to) {
- if (IsGood(from)) {
- ++grow_days_cnt;
- }
- ++from;
- }
- cout << grow_days_cnt;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement