3209: The number proposition of the flower God Time limit: ten Sec Memory Limit: MB
Submit: 1612 Solved: 746
[Submit] [Status] [Discuss] Description
Background
As we all know, the flower God over the years by virtue of the boundless power of the big OJ, OI, CF, TC ... Of course it also includes CH.
Describe
The flower God comes to lecture again this day. After class, there is a very difficult god problem. I waited for Konjac Konjac to suffer again.
The topic of the flower God is this
Set sum (i) to indicate the number of 1 in the binary representation of I. Give a positive integer N, the flower God wants to ask you
Pie (sum (i)), which is the product of sum (1)-sum (N).
Input
A positive integer N.
Output
A number, the value of the answer modulus 10000007.
Sample InputSample Input One
3
Sample OutputSample Output One
2
HINT
For example one, 1*1*2=2;
Data scope and conventions
For 100% of data, n≤10^15
Source
Original Memphis
Digital DP + Number theory
F[X] Indicates the number of sum[i]=x I, then the final answer equals (1^f[1]) * (2^f[2]) * (3^f[3]) * ...
Because the base range is very small, and the 10000007=941*10627, so the basis and 100,000,071 fixed coprime, according to Euler theorem, as long as the exponent of Phi (10000007) =9988440 to take the model.
The question now is how to ask for f[x].
Digital DP from high to low, see procedure in detail.
Why all kinds of DP can't think of it ... (╯‵-′) ╯︵┻━┻
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath > #include <algorithm> #define F (I,j,n) for (int. i=j;i<=n;i++) #define D (i,j,n) for (int i=j;i>=n;i--) # Define ll long long#define MoD 10000007#define phi 9988440using namespace Std;ll n,ans=1,c[60][60],f[60];inline ll read () { ll X=0,f=1;char Ch=getchar (); while (ch< ' 0 ' | | Ch> ' 9 ') {if (ch== '-') F=-1;ch=getchar ();} while (ch>= ' 0 ' &&ch>= ' 9 ') {x=x*10+ch-' 0 '; Ch=getchar ();} return x*f;} inline void DP (LL x) {int tmp=0,cnt=0;ll now=0;while ((1ll<<tmp) <x) tmp++;D(i,tmp,0) if (now+ (1ll<<i) < =x) {F (J,0,i) (F[j+cnt]+=c[i][j])%=phi;cnt++;now+= (1ll<<i);}} inline ll Getpow (ll X,ll y) {ll ret=1;for (; y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;} int main () {scanf ("%lld", &n); F (i,0,50) {c[i][0]=1; F (j,1,i) c[i][j]= (c[i-1][j-1]+c[i-1][j])%phi; DP (N+1); F (i,1,50) Ans=ans*getpow (I,f[i])%mod;printf ("%lld\n", ans);
The maths problem of bzoj3209 flower God