結果
| 問題 |
No.2526 Kth Not-divisible Number
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-04-02 17:27:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 709 bytes |
| コンパイル時間 | 978 ms |
| コンパイル使用メモリ | 104,080 KB |
| 最終ジャッジ日時 | 2025-02-11 22:20:17 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 11 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
using ll = long long;
ll A, B, C, K;
bool solve(ll X){
return X-(X/A+X/B-X/C) <= K;
}
int main(){
cin >> A >> B >> K;
C = A*B/gcd(A,B);
ll l=0, r=9e18, c;
while(r-l>1){
c = (l+r)/2;
if (solve(c)) l=c;
else r=c;
}
ll mi=max(1LL, l-5);
for (ll X=mi; X<=l; X++){
if (X-(X/A+X/B-X/C) == K && X % A != 0 && X % B != 0){
cout << X << endl;
return 0;
}
}
return 0;
}
srjywrdnprkt