結果

問題 No.2526 Kth Not-divisible Number
ユーザー inkyamaninkyaman
提出日時 2024-03-24 15:56:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 118,840 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-24 15:56:47
合計ジャッジ時間 8,116 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
6,676 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

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