-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
49 lines (46 loc) · 1.1 KB
/
A.cpp
File metadata and controls
49 lines (46 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;
int main()
{ _
lli t, n; cin >> t;
while(t--) {
cin >> n;
lli nn = n;
bool b = n % 2;
n -= n % 2;
lli ans = 0;
while(n) {
if(n == 4) {
ans += 3;
break;
}
if(n % 4 == 0) {
++ans;
n -= 2;
continue;
}
if(n % 2 == 0) {
ans += n / 2;
n /= 2;
--n;
continue;
}
}
if(b) ans = (nn - ans);
cout << ans << ENDL;
}
return 0;
}