luyencode / comments

Server lưu trữ bình luận trên Luyện Code
https://luyencode.net
6 stars 3 forks source link

https://oj.luyencode.net/problem/TASKSET #851

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Chi tiết bài tập - undefined

https://oj.luyencode.net/problem/TASKSET

hoangdev0 commented 1 year ago

Đây là lời giải của mình đã AC. C++.

Xem code AC

```c++ #include #define fast() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) using namespace std; typedef long long ll; // const int N = 1e6+2; // int n; ll th1(ll n) { ll res(1); while (res * 2 < n) res *= 2; return n - res; } ll th2(ll n) { ll res(3); while (res * 2 < n) res *= 2; return n - res; } int main() { fast(); ll n; cin >> n; ll x = th1(n), y = th2(n); if (x == 0 || y == 0) cout << 0; else cout << min(x, y); return 0; } ```