結果
問題 |
No.2526 Kth Not-divisible Number
|
ユーザー |
|
提出日時 | 2023-11-03 21:31:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 697 bytes |
コンパイル時間 | 1,835 ms |
コンパイル使用メモリ | 191,932 KB |
最終ジャッジ日時 | 2025-02-17 17:44:25 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 WA * 3 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} 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 l=A*B/gcd(A,B); ll ng=0,ok=1LL<<61; while(abs(ng-ok)>1){ ll mid=(ok+ng)/2; if(mid-mid/A-mid/B+mid/l>=K)ok=mid; else ng=mid; } cout<<ok<<"\n"; } }