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;
}
本文来自博客园,作者:O2iginal,转载请注明原文链接:https://www.cnblogs.com/o2iginal/p/17495472.html