結果
| 問題 |
No.1350 2019-6problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-17 15:49:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 6,078 bytes |
| コンパイル時間 | 1,622 ms |
| コンパイル使用メモリ | 167,412 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-29 18:52:01 |
| 合計ジャッジ時間 | 2,333 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
//#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include "bits/stdc++.h"
#pragma region library
#pragma region Macros
#define EXPAND(x) x
#define _overload4(_1, _2, _3, _4, name, ...) name
#define _overload5(_1, _2, _3, _4, _5, name, ...) name
#define rep1(i, n) for (decltype(n) i = 0; i < (n); ++i)
#define rep2(i, a, b) for (decltype(b) i = static_cast<decltype(b)>(a); i < (b); ++i)
#define rep3(i, a, b, c) for (decltype(b) i = static_cast<decltype(b)>(a); i < (b); i += static_cast<decltype(b)>(c))
#define rept(...) EXPAND(_overload4(__VA_ARGS__, rep3, rep2, rep1, )(__VA_ARGS__))
#define per1(i, n) for (decltype(n) i = (n); i >= 0; --i)
#define per2(i, a, b) for (decltype(a) i = (a); i >= static_cast<decltype(a)>(b); --i)
#define per3(i, a, b, c) for (decltype(a) i = (a); i >= static_cast<decltype(a)>(b); i -= static_cast<decltype(a)>(c))
#define pert(...) EXPAND(_overload4(__VA_ARGS__, per3, per2, per1, )(__VA_ARGS__))
#define var_1(T, a) T a; read(a);
#define var_2(T, a, b) T a, b; read(a, b);
#define var_3(T, a, b, c) T a, b, c; read(a, b, c);
#define var_4(T, a, b, c, d) T a, b, c, d; read(a, b, c, d);
#define var(...) EXPAND(_overload5(__VA_ARGS__, var_4, var_3, var_2, var_1, )(__VA_ARGS__))
#define itrall(x) std::begin(x), std::end(x)
using i16 = short;
using i32 = int;
using i64 = long long;
#pragma endregion
#ifndef CnM_library
#define debug(x)
constexpr int dx[] = { 0, 0, -1, 0 };
constexpr int dy[] = { -1, 1, 0, -1 };
template <class T> static constexpr T INF = std::numeric_limits<T>::max() / 2;
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
#define elif else if
#define len(T) (int)(T).size()
template <class T, class U> inline bool ckmax(T& A, const U& B) { return B > A ? A = B, true : false; }
template <class T, class U> inline bool ckmin(T& A, const U& B) { return B < A ? A = B, true : false; }
struct setup_ios_deci {
setup_ios_deci() { std::cout << std::fixed << std::setprecision(15); }
} setup_ios_deci_;
namespace lib {
template <class T, class U> inline T Pow(T A, U B) { T res(1); while (B) { if (B & 1) res *= A; A *= A; B >>= 1; } return res; }
inline long long gcd(long long A, long long B) { while (B) { const long long C = A; A = B; B = C % B; } return A; }
inline long long lcm(const long long A, const long long B) { return A / gcd(A, B) * B; }
inline long long extgcd(long long A, long long B, long long& X, long long& Y) {
long long D = A; if (B != 0) { D = extgcd(B, A % B, Y, X); Y -= (A / B) * X; return D; }
else { X = 1; Y = 0; return A; }
}
inline long long modpow(long long A, long long B, const long long MOD) {
long long res(1); while (B) { if (B & 1) res *= A, res %= MOD; A *= A; A %= MOD; B >>= 1; } return res;
}
template <class T> inline T inverse(T A, const T M) {
T B = M, U = 1, V = 0; while (B) { T t = A / B; A -= t * B; std::swap(A, B); U -= t * V; std::swap(U, V); }
U %= M; return U < 0 ? U += M, U : U;
}
}
inline void read_sub(long long& ret) {
ret = 0; bool plus_minus = true; char ch = getchar_unlocked(); while (isspace(ch)) { ch = getchar_unlocked(); }
if (ch == '-') { plus_minus = false; ch = getchar_unlocked(); }
for (; isdigit(ch); ch = getchar_unlocked()) { ret = (ret * 10ll) + ((long long)ch - (long long)'0'); }
ungetc(ch, stdin); ret = (plus_minus ? ret : -ret); return;
}
inline void read_sub(int64_t& ret) {
ret = 0; bool plus_minus = true; char ch = getchar_unlocked(); while (isspace(ch)) { ch = getchar_unlocked(); }
if (ch == '-') { plus_minus = false; ch = getchar_unlocked(); }
for (; isdigit(ch); ch = getchar_unlocked()) { ret = (ret * 10ll) + ((int64_t)ch - (int64_t)'0'); }
ungetc(ch, stdin); ret = (plus_minus ? ret : -ret); return;
}
inline void read_sub(int& ret) {
ret = 0; bool plus_minus = true; char ch = getchar_unlocked(); while (isspace(ch)) { ch = getchar_unlocked(); }
if (ch == '-') { plus_minus = false; ch = getchar_unlocked(); }
for (; isdigit(ch); ch = getchar_unlocked()) { ret = (ret * 10) + ((int)ch - (int)'0'); }
ungetc(ch, stdin); ret = (plus_minus ? ret : -ret); return;
}
inline void read_sub(short& ret) {
ret = 0; bool plus_minus = true; char ch = getchar_unlocked(); while (isspace(ch)) { ch = getchar_unlocked(); }
if (ch == '-') { plus_minus = false; ch = getchar_unlocked(); }
for (; isdigit(ch); ch = getchar_unlocked()) { ret = (ret * 10) + ((int)ch - (int)'0'); }
ungetc(ch, stdin); ret = (plus_minus ? ret : -ret); return;
}
inline void read_sub(double& ret) { std::cin >> ret; return; }
inline void read_sub(long double& ret) { std::cin >> ret; return; }
inline void read_sub(char& ret) { ret = getchar_unlocked(); while (isspace(ret)) { ret = getchar_unlocked(); } return; }
inline void read_sub(std::string& ret) {
char ch = getchar_unlocked(); ret = ""; while (isspace(ch)) { ch = getchar_unlocked(); }
for (; !isspace(ch); ch = getchar_unlocked()) { ret += ch; } ungetc(ch, stdin); return;
}
template <class T, class U> inline void read_sub(std::pair<T, U>& ret) { read_sub(ret.first); read_sub(ret.second); return; }
template <class T> inline void read_sub(std::vector<T>& ret) { for (T& r : ret) { read_sub(r); } return; }
template <class T> inline void read(T& Tar) { read_sub(Tar); return; }
template <class T, class... Ts> inline void read(T& Tar, Ts&... ts) { read_sub(Tar); read(ts...); return; }
template <class T> inline void print(T Target) { std::cout << Target; return; }
template <class T, class... Ts> inline void print(T Target, Ts... ts) { std::cout << Target; print(ts...); return; }
#endif
#pragma endregion
struct TaskA {
void solve() {
i64 A, B, K; read(A, B, K);
i64 right = INF<i64>, left = 0;
while (right - left > 1) {
i64 mid = (right + left) / 2;
i64 S = mid / A + mid / B;
S -= mid / (lib::lcm(A, B));
if (S >= K) right = mid;
else left = mid;
}
print(right, '\n');
}
};
int main(void) {
TaskA solver;
solver.solve();
return 0;
}