結果

問題 No.2526 Kth Not-divisible Number
ユーザー planesplanes
提出日時 2023-11-03 21:43:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 620 bytes
コンパイル時間 2,099 ms
コンパイル使用メモリ 166,940 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-03 21:43:32
合計ジャッジ時間 16,142 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=3e18+100;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);
  


ll t;cin>>t;
for(ll i=0;i<t;i++) {
  ll A,B,K;cin>>A>>B>>K;

  ll s=1;
  ll g=INF;

  while(s<g) {
    ll k=(s+g)/2;
   ll lcm=A*B/GCD(A,B);
    ll count=k-(k/A)-(k/B)+(k/lcm);
    if(count>=K) g=k;
    else s=k+1;

  }
  


  cout<<s<<'\n';
}

}
0