結果

問題 No.2526 Kth Not-divisible Number
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-11-03 20:07:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 762 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 1,011 ms
コンパイル使用メモリ 107,844 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-03 21:29:54
合計ジャッジ時間 8,244 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 762 ms
4,348 KB
testcase_04 AC 754 ms
4,348 KB
testcase_05 AC 755 ms
4,348 KB
testcase_06 AC 755 ms
4,348 KB
testcase_07 AC 748 ms
4,348 KB
testcase_08 AC 495 ms
4,348 KB
testcase_09 AC 489 ms
4,348 KB
testcase_10 AC 515 ms
4,348 KB
testcase_11 AC 454 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = unsigned long long;

ll A, B, K;

bool judge(ll X){
    return X-(X/A+X/B-X/lcm(A, B)) >= K;
}

void solve(){

    cin >> A >> B >> K;

    ll l=0, r=9e18, c;
    while(r-l>1){
        c = (l+r)/2;
        if (judge(c)) r=c;
        else l=c;
    }
  
    cout << r << endl;
    assert(r % A != 0 && r % B != 0);
    return;
}

int main(){

    ll T;
    cin >> T;

    while(T){
        T--;
        solve();
    }

    return 0;
}
0