結果
| 問題 |
No.2526 Kth Not-divisible Number
|
| コンテスト | |
| ユーザー |
keisuke6
|
| 提出日時 | 2023-11-03 21:53:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 405 bytes |
| コンパイル時間 | 2,262 ms |
| コンパイル使用メモリ | 193,428 KB |
| 最終ジャッジ日時 | 2025-02-17 18:09:19 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int T;
cin>>T;
while(T--){
int a,b,k;
cin>>a>>b>>k;
int t = lcm(a,b);
int ad = (k/(t-t/a-t/b+1))*t;
k %= (t-t/a-t/b+1);
if(k == 0){
cout<<ad-1<<endl;
continue;
}
int l = 1, r = t;
while(r-l > 1){
int md = (l+r)/2;
if(md-md/a-md/b <= k) l = md;
else r = md;
}
cout<<ad+l<<endl;
}
}
keisuke6