結果

問題 No.2526 Kth Not-divisible Number
ユーザー karinohitokarinohito
提出日時 2023-11-03 22:49:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 319 bytes
コンパイル時間 2,387 ms
コンパイル使用メモリ 201,836 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-11-03 22:49:51
合計ジャッジ時間 7,713 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 465 ms
4,348 KB
testcase_04 AC 449 ms
4,348 KB
testcase_05 AC 448 ms
4,348 KB
testcase_06 AC 449 ms
4,348 KB
testcase_07 AC 472 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;
void solve(){
    ll A,B,K;
    cin>>A>>B>>K;
    ll G=A/gcd(A,B)*B,L=0,R=4e18;
    while(R-L>1){
        ll M=(R+L)/2,a=(M/A)+(M/B)-(M/G);
        (M-a<=K?L:R)=M;
    }
    cout<<L<<endl;
}

int main() {
    ll T;
    cin>>T;
    while(T--)solve();
}
0