結果
問題 |
No.2526 Kth Not-divisible Number
|
ユーザー |
|
提出日時 | 2023-11-03 22:08:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 591 ms / 2,000 ms |
コード長 | 519 bytes |
コンパイル時間 | 4,069 ms |
コンパイル使用メモリ | 249,916 KB |
最終ジャッジ日時 | 2025-02-17 18:22:42 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) using mint = atcoder::modint998244353; ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b); } int main(){ int t; cin>>t; rep(Ti,t){ ll a,b,k; cin>>a>>b>>k; ll l=a/gcd(a,b)*b; ll up=9e18; ll dw=0; while(up-dw>1){ ll md=((__int128_t)up+dw)/2; ll ct=0; ct+=md/a; ct+=md/b; ct-=md/l; if(md-ct>=k) up=md; else dw=md; } cout<<up<<"\n"; } }