Test instructions: Given an n, ask how many odd numbers you have in C (n, 0)-C (n, N).
Analysis: Lucas theorem, C (B[i], a[i]), as long as not 0, then is odd, then b[i], is fixed, that is, a[i] only b[i]+1 kind of situation. The last ride is good.
The code is as follows:
#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include <cstdio> #include <string> #include < cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include < queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include < cmath> #include <stack> #include <ctime> #include <cstdlib> #define DEBUG puts ("+++++")//#include <tr1/unordered_map> #define FREOPENR freopen ("In.txt", "R", stdin) #define FREOPENW freopen ("OUT.txt", "w", stdout ) using namespace std;//using namespace std:: tr1;typedef Long Long ll;typedef pair<int, int> p;const int INF = 0x3f 3f3f3f;const double inf = 0x3f3f3f3f3f3f;const LL LNF = 0x3f3f3f3f3f3f;const Double PI = ACOs ( -1.0); const double EPS = 1e- 8;const int MAXN = 1e6 + 5;const LL mod = 1e9 + 7;const int N = 1e6 + 5;const int dr[] = {-1, 0, 1, 0, 1, 1,-1, -1};const int dc[] = {0, 1, 0,-1, 1,-1, 1, -1};const Char *hex[]= {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};inline ll gcd (ll A, ll b) {return b = = 0? a:gcd (b, a%b);} inline int gcd (int a, int b) {return b = = 0? a:gcd (b, a%b);} inline int LCM (int a, int b) {return a * B/GCD (a, b);} int n, m;const int mon[] = {0, 31, 29, 31, 30, 31, 0, +, +,, +, +, +,, N, H, H, C, h, 31};inline int Min (int a, int b) {return a < b? A:b;} inline int Max (int a, int b) {return a > b a:b;} inline ll Min (ll A, ll b) {return a < b a:b;} inline ll Max (ll A, ll b) {return a > b a:b;} inline bool Is_in (int r, int c) {return R >= 0 && r < n && C >= 0 && C < m;} int main () {while (scanf ("%d", &n) = = 1) {int ans = 1; while (n) {ans *= n% 2 + 1; n/= 2; } printf ("%d\n", ans); } return 0;}
HDU 4349 Xiao Ming ' s Hope (Lucas)