正文
增加 12 行删除 12 行
28 行未改动293031323334353637383940414243444546474849505152535455565758596061626364656667686928 行未改动bool check(LL x){LL ans = x;LL t = x;while(true){LL f = (t / 3);if(f == 0) break;ans += f;t = (t % 3);t += f;}if(ans >= n) return true;else return false;}int find(LL n){LL l = 1,r = n;while(l + 1 < r){LL mid = (l + r) / 2;if(check(mid)) r = mid;else l = mid;}if(check(l)) return l;else return r;}int main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);cin >> n;cout << find(n);return 0;}```28 行未改动293031323334353637383940414243444546474849505152535455565758596061626364656667686928 行未改动bool check(LL x){LL ans = x;LL t = x;while(true){LL f = (t / 3);if(f == 0) break;ans += f;t = (t % 3);t += f;}if(ans >= n) return true;else return false;}int find(LL n){LL l = 1,r = n;while(l + 1 < r){LL mid = (l + r) / 2;if(check(mid)) r = mid;else l = mid;}if(check(l)) return l;else return r;}int main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);cin >> n;cout << find(n);return 0;}```