二进制

 1 https://www.cnblogs.com/nysanier/archive/2011/04/19/2020778.html
 2 
 3 
 4 #include <iostream>
 5 #include <cstdio>
 6 #include <algorithm>
 7 #include <cstring>
 8 #include <vector>
 9 #include <utility>
10 #include <queue>
11 #include <set>
12 using namespace std;
13 typedef long long ll;
14 const int N=1e5+6;
15 int n;
16 int  main()
17 
18 {
19     while(~scanf("%d",&n)){
20         printf("%d
",__builtin_clz(n));//返回左起第一个‘1’之前0的个数。
21         printf("%d
",__builtin_ctz(n));//返回右起第一个‘1’之后的0的个数。
22         printf("%d
",__builtin_popcount(n));//返回‘1’的个数。
23         printf("%d
",__builtin_ffs(n));//返回右起第一个‘1’的位置。
24     }
25     /*
26         20:0000000000000000000000000010100
27         27
28         2
29         2
30         3
31 
32     return 0;
33 }
原文地址:https://www.cnblogs.com/tingtin/p/9367193.html