結果

問題 No.2526 Kth Not-divisible Number
ユーザー SSRSSSRS
提出日時 2023-11-03 21:24:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 473 bytes
コンパイル時間 1,860 ms
コンパイル使用メモリ 202,016 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-03 21:25:13
合計ジャッジ時間 7,459 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    long long A, B, K;
    cin >> A >> B >> K;
    long long L = lcm(A, B);
    long long tv = 0, fv = 6100000000000000000;
    while (fv - tv > 1){
      long long mid = tv + (fv - tv) / 2;
      long long cnt = mid - mid / A - mid / B + mid / L;
      if (cnt <= K){
        tv = mid;
      } else {
        fv = mid;
      }
    }
    cout << tv << endl;
  }
}
0