結果
問題 |
No.2526 Kth Not-divisible Number
|
ユーザー |
![]() |
提出日時 | 2023-11-03 22:04:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 261 ms / 2,000 ms |
コード長 | 599 bytes |
コンパイル時間 | 613 ms |
コンパイル使用メモリ | 80,296 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 20:24:43 |
合計ジャッジ時間 | 4,243 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 |
ソースコード
#include <iostream> #include <numeric> using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); int T; cin >> T; while (T--) { long long A, B, K; cin >> A >> B >> K; const auto l = std::lcm(A, B); long long ng = K - 1, ok = 1LL << 62; while (ok - ng > 1) { const auto mid = (ok + ng) / 2; auto nin = mid - mid / A - mid / B + mid / l; if (nin >= K) { ok = mid; } else { ng = mid; } } cout << ok << '\n'; } }