結果

問題 No.2526 Kth Not-divisible Number
ユーザー otoshigo
提出日時 2023-11-03 21:28:07
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
(最新)
CE  
(最初)
実行時間 -
コード長 761 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 107,744 KB
最終ジャッジ日時 2025-02-17 17:38:05
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
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