結果
問題 |
No.2526 Kth Not-divisible Number
|
ユーザー |
|
提出日時 | 2024-07-13 19:32:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 611 ms / 2,000 ms |
コード長 | 603 bytes |
コンパイル時間 | 3,702 ms |
コンパイル使用メモリ | 275,156 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-13 19:32:44 |
合計ジャッジ時間 | 10,496 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define int long long const int MOD = 998244353; void solve() { int a, b, k; cin >> a >> b >> k; int l = 1, r = LONG_LONG_MAX; while (l < r) { int mid = l + (r - l) / 2; int count = mid - mid / a - mid / b + mid / (lcm(a, b)); if(count < k) { l = mid + 1; } else { r = mid; } } cout << l << endl; } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); int T = 1; cin >> T; while (T--) { solve(); } return 0; }