一道简单的数位DP.
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 #define ll long long 6 #define FILE "dealing" 7 #define up(i,j,n) for(int i=j;i<=n;i++) 8 #define db long double 9 #define pii pair<int,int> 10 #define pb push_back 11 #define mem(a,L) memset(a,0,sizeof(int)*(L+1)) 12 template<class T> inline bool cmin(T& a,T b){return a>b?a=b,true:false;} 13 template<class T> inline bool cmax(T& a,T b){return a<b?a=b,true:false;} 14 template<class T> inline T squ(T a){return a*a;} 15 const ll maxn=210000+10,inf=1e9+10,mod=10000007,M=9988440; 16 ll read(){ 17 ll x=0,f=1,ch=getchar(); 18 while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} 19 while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar(); 20 return x*f; 21 } 22 ll n; 23 int w[70]; 24 ll c[70][70]; 25 ll num[70]; 26 ll qpow(ll a,ll b){ 27 ll ans=1; 28 while(b){ 29 if(b&1)ans=ans*a%mod; 30 a=a*a%mod; 31 b>>=1; 32 } 33 return ans; 34 } 35 int main(){ 36 freopen(FILE".in","r",stdin); 37 freopen(FILE".out","w",stdout); 38 n=read();int s=0; 39 while(n){ 40 w[++w[0]]=n&1; 41 if(n&1)s++; 42 n>>=1; 43 } 44 c[0][0]=1; 45 for(int i=1;i<=w[0];i++){ 46 c[i][0]=1; 47 for(int j=1;j<=w[0];j++) 48 c[i][j]=(c[i-1][j-1]+c[i-1][j])%M; 49 } 50 int k=0; 51 for(int i=w[0];i>=1;i--){ 52 if(w[i]==1){ 53 for(int j=0;j<i;j++) 54 (num[j+k]+=c[i-1][j])%=M; 55 k++; 56 } 57 } 58 num[s]++; 59 ll ans=1; 60 for(int i=1;i<60;i++) 61 ans=ans*qpow(i,num[i])%mod; 62 printf("%lld ",ans); 63 return 0; 64 }