题意是求,n是1e15,枚举1的个数,数位dp
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+10;
const int p=10000007;
int p2;
ll num[60], dp[60][60][60];
/*************************/ //O(sqrt(n))
ll eular(ll n){
ll ans=n;
for(int i=2; i*i<=n; i++)
if(n%i==0){
ans-=ans/i;
while(n%i==0)
n/=i;
}
if(n>1) ans-=ans/n;
return ans;
}
/*****************************/
ll dfs(int pos, bool limit, int s, int tar){
if(pos==0)
return s==tar;
if(s>tar || s+pos<tar) return 0;
if(!limit && dp[tar][pos][s]!=-1)
return dp[tar][pos][s];
int up=limit ? num[pos]:1;
ll ret=0;
for(int i=0; i<=up; i++)
ret=(ret+dfs(pos-1, limit&&(i==up), s+i, tar))%p2;
return limit ? ret : dp[tar][pos][s]=ret;
}
ll qpow(ll bas, ll m){
ll ans=1;
while(m){
if(m&1)
ans=ans*bas%p;
m>>=1;
bas=bas*bas%p;
}
return ans;
}
void solve(ll n){
memset(dp, -1, sizeof dp);
int cnt=0;
while(n){
num[++cnt]=n&1;
n>>=1;
}
ll ans=1;
for(int i=1; i<=cnt; i++){
ll tmp=dfs(cnt, 1, 0, i);
tmp+=p2;
ans=ans*qpow(i, tmp)%p;
}
printf("%lld\n", ans);
}
int main()
{
p2=eular(p);
ll n;
scanf("%lld", &n);
solve(n);
return 0;
}