結果

問題 No.2526 Kth Not-divisible Number
ユーザー inkyaman
提出日時 2024-03-24 15:56:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 932 ms
コンパイル使用メモリ 114,696 KB
最終ジャッジ日時 2025-02-20 13:39:47
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 1 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;

int T;

int main() {

    cin >> T;
    vector<ll> ans;
    while(T--) {
        ll A, B, K;
        cin >> A >> B >> K;
        ll l = 0, r = 3e18;
        while(r-l > 1) {
            ll mid = l+(r-l)/2;
            ll t = mid;
            t -= mid/A;
            t -= mid/B;
            t += mid/(A*B);
            if(t >= K) r = mid;
            else l = mid;
        }

        ans.push_back(r);
        
    }

    for(auto v : ans) cout << v << endl;

}
0