So that sum (I) is the number of I in binary, evaluate sum (1 <= I <= N) sum (I)
A very simple digital DP. First, we create a table and then use the digital DP to calculate the number of the numbers of 1 in the binary system as X. Finally, we output the limit (1 <= x <= logn) x ^ ans [x]
The question lies inThe result of the combination of the number and the number of digits DP is that the exponential modulo cannot be obtained directly using PHI (P)
So we took the modulo of 10000006 and then the question was wa, because10000007 is not a prime number!
10000007 = 941*10627 so we can get PHI (p) = 940*10626 = 9988440 modulo this number.
In fact, it can be done without mod. It will not be long... Why am I doing this...
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#define M 10000007#define Phi_M 9988440using namespace std;typedef long long ll;ll n,f[60][60],ans[60],output=1;void Digital_DP(ll x){int i,j,cnt=0;ll now=0;for(i=1;1ll<<i<=x;i++);for(;~i;i--)if(now+(1ll<<i)<=x){for(j=0;j<=i;j++)ans[j+cnt]=(ans[j+cnt]+f[i][j])%Phi_M;++cnt;now+=(1ll<<i);}}ll Quick_Power(ll x,ll y){ll re=1;while(y){if(y&1)re*=x,re%=M;x*=x,x%=M;y>>=1;}return re;}int main(){int i,j;for(i=0;i<=55;i++){f[i][0]=1;for(j=1;j<=i;j++)f[i][j]=(f[i-1][j]+f[i-1][j-1])%Phi_M;}cin>>n;Digital_DP(n+1);for(i=1;i<=55;i++)output*=Quick_Power(i,ans[i]),output%=M;cout<<output<<endl;}
Bzoj 3209 digital topic digital DP + Number Theory