結果

問題 No.2526 Kth Not-divisible Number
ユーザー 👑 hitonanodehitonanode
提出日時 2023-11-03 22:04:33
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 80,172 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-03 22:04:38
合計ジャッジ時間 4,616 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 266 ms
4,348 KB
testcase_04 AC 266 ms
4,348 KB
testcase_05 AC 266 ms
4,348 KB
testcase_06 AC 268 ms
4,348 KB
testcase_07 AC 267 ms
4,348 KB
testcase_08 AC 247 ms
4,348 KB
testcase_09 AC 242 ms
4,348 KB
testcase_10 AC 249 ms
4,348 KB
testcase_11 AC 234 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
    }
}
0