結果

問題 No.2526 Kth Not-divisible Number
ユーザー otoshigootoshigo
提出日時 2023-11-03 21:28:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 4,226 ms
コンパイル使用メモリ 201,816 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-03 21:29:13
合計ジャッジ時間 5,984 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--){
        ll A,B,K;
        cin>>A>>B>>K;
        ll l=A*B/gcd(A,B);
        ll ok=0,ng=numeric_limits<ll>::max();
        while(ng-ok>1){
            ll mid=(ok+ng)/2;
            if(mid-mid/A-mid/B+mid/l<=K)ok=mid;
            else ng=mid;
        }
        cout<<ok<<"\n";
    }
}
0