abc050d <???>

#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
map<LL, LL> mp;
const LL mod = 1e9 + 7;

LL f(LL n)
{
    if (mp[n]) return mp[n];
    if (n & 1)
    {
        return mp[n] = (f(n / 2) * 2  + f(n / 2 - 1)) % mod;
    }
    else
    {
        return mp[n] = (f(n / 2) + f(n / 2 - 1) * 2) % mod;
    }
}

void solv()
{
    mp[0] = 1;
    mp[1] = 2;
    LL n;
    cin >> n;
    cout << f(n) << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T --)
    {
        solv();
    }
    return 0;
}
posted @ 2023-06-21 09:35  O2iginal  阅读(19)  评论(0)    收藏  举报