File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ #define lli long long int
3
+ #define endl " \n "
4
+ #define MAX 1000005
5
+ #define MOD 1000000007
6
+ using namespace std ;
7
+
8
+
9
+ int main ()
10
+ {
11
+ int t;
12
+ cin>>t;
13
+ while (t--)
14
+ {
15
+ int n;
16
+ cin>>n;
17
+ if (n%2 )
18
+ {
19
+ cout<<n<<endl;
20
+ continue ;
21
+ }
22
+ bitset <32 > b1 (n);
23
+ string s = b1.to_string ();
24
+ int i = 0 ;
25
+ for (; i <32 ;i++)
26
+ if (s[i] == ' 1' )
27
+ break ;
28
+ s = s.substr (i);
29
+ reverse (s.begin (), s.end ());
30
+ bitset <32 > b2 (s);
31
+ cout<<b2.to_ulong ()<<endl;
32
+ }
33
+ return 0 ;
34
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ #define lli long long int
3
+ #define endl " \n "
4
+ #define MAX 1000005
5
+ #define MOD 1000000007
6
+ using namespace std ;
7
+
8
+
9
+ int main ()
10
+ {
11
+ int t;
12
+ cin>>t;
13
+ while (t--)
14
+ {
15
+ int n;
16
+ cin>>n;
17
+ if (n%2 )
18
+ {
19
+ cout<<n<<endl;
20
+ continue ;
21
+ }
22
+ bitset <32 > b1 (n);
23
+ string s = b1.to_string ();
24
+ int i = 0 ;
25
+ for (; i <32 ;i++)
26
+ if (s[i] == ' 1' )
27
+ break ;
28
+ s = s.substr (i);
29
+ reverse (s.begin (), s.end ());
30
+ bitset <32 > b2 (s);
31
+ cout<<b2.to_ulong ()<<endl;
32
+ }
33
+ return 0 ;
34
+ }
You can’t perform that action at this time.
0 commit comments