Question: Chinese.
Idea: like the common digit DP, convert it to binary here and record several items,
Just multiply the statistics.
Code:
# Include "cstdlib" # include "cstdio" # include "cstring" # include "cmath" # include "stack" # include "algorithm" # include "iostream" using namespace STD; long long DP [66] [66]; int M = 10000007; int num [66]; long DFS (INT site, int N, int F) {If (Site = 0) return n? N: 1; // note that it is the product, so 1 If (! F & DP [site] [N]! =-1) return DP [site] [N]; int Len = f? Num [site]: 1; long ans = 1; // The initial value of ANS is 1 for (INT I = 0; I <= Len; I ++) {if (I = 0) ans * = DFS (site-1, n, F & I = Len); else ans * = DFS (site-1, n + 1, F & I = Len); If (ANS> = m) ans % = m;} If (! F) DP [site] [N] = ans % m; return ans % m;} long solve (long x) {int CNT = 0; while (X) {num [++ CNT] = x % 2; X/= 2;} return DFS (CNT, 0, 1) % m;} int main () {long N; memset (DP,-1, sizeof (DP); While (scanf ("% LLD", & N )! =-1) {printf ("% LLD \ n", solve (n);} return 0 ;}
[Digital DP] bzoj 3209 the number of flowers and gods