結果
問題 | No.1350 2019-6problem |
ユーザー |
![]() |
提出日時 | 2021-01-17 13:20:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 1,733 ms |
コンパイル使用メモリ | 191,720 KB |
最終ジャッジ日時 | 2025-01-18 00:25:43 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define ALL(v) v.begin(), v.end() using namespace std; using P = pair<int, int>; typedef long long ll; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int main() { ll a, b, k; cin >> a >> b >> k; ll d = lcm(a, b); ll left = 0; ll right = 1000000000000000000; while (right - left > 1){ ll mid = (right + left) / 2; auto ok = [&](ll x) { ll num = (x / a) + (x / b) - (x / d); return num >= k; }; if(ok(mid)){ right = mid; }else{ left = mid; } } cout << right << endl; }