結果
問題 | No.2526 Kth Not-divisible Number |
ユーザー |
![]() |
提出日時 | 2024-09-10 10:11:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 283 ms / 2,000 ms |
コード長 | 549 bytes |
コンパイル時間 | 1,938 ms |
コンパイル使用メモリ | 191,940 KB |
最終ジャッジ日時 | 2025-02-24 06:30:15 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 |
ソースコード
#include<bits/stdc++.h>using namespace std;template<typename T>T gcd(T a, T b){return b==0?a:gcd(b,a%b);}template<typename T>T lcm(T a, T b){return a/gcd(a,b)*b;}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin>>T;while(T--){long A,B,K;cin>>A>>B>>K;long C=lcm(A,B);long L=0,R=3e18;while(R-L>1){long mid=(L+R)/2;long cnt=mid-(mid/A+mid/B-mid/C);(cnt>=K?R:L)=mid;}cout<<R<<'\n';}}