File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ class Solution
2+ {
3+ public:
4+ int hammingWeight (uint32_t n)
5+ {
6+ uint32_t temp = n;
7+ unsigned int count = 0 ;
8+ while (n)
9+ {
10+ count += (n & 1 );
11+ n >>= 1 ;
12+ }
13+ return count;
14+ }
15+ };
16+
17+ // author:Chinmay Lohani
18+ // date:9-3-2022
19+ // problemName:A. Deletions of Two Adjacent Letters
20+ // problemLink:https://codeforces.com/contest/1650/problem/A
21+ // memoryLimit: 256
22+ // timeLimit:2000
23+
24+ #include < bits/stdc++.h>
25+
26+ using namespace std ;
27+
28+ #define mod 998244353
29+ #define lli long long int
30+ #define ll long long
31+ #define li long int
32+ #define FastIO \
33+ ios::sync_with_stdio (0 ); \
34+ cin.tie(0 )
35+
36+ uint32_t solve ();
37+ int main ()
38+ {
39+ FastIO;
40+ ll tc;
41+ cin >> tc;
42+ while (tc--)
43+ {
44+ cout << solve ();
45+ }
46+ return 0 ;
47+ }
48+ uint32_t solve ()
49+ {
50+ uint32_t n;
51+ cin >> n;
52+ uint32_t temp = n;
53+ unsigned int count = 0 ;
54+ while (n)
55+ {
56+ count += (n & 1 );
57+ n >>= 1 ;
58+ }
59+ return count;
60+ }
You can’t perform that action at this time.
0 commit comments