結果
| 問題 |
No.2526 Kth Not-divisible Number
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2023-11-03 22:46:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 370 ms / 2,000 ms |
| コード長 | 530 bytes |
| コンパイル時間 | 1,692 ms |
| コンパイル使用メモリ | 192,108 KB |
| 最終ジャッジ日時 | 2025-02-17 18:39:04 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
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 c=lcm(a,b);
auto f=[&](ll x){
return x-x/a-x/b+x/c;
};
ll ok=8e18+1,ng=0;
while(ok-ng>1){
ll mid=(ok+ng)/2;
if(f(mid)>=k) ok=mid;
else ng=mid;
}
cout<<ok<<endl;
}
return 0;
}
umezo