// No.604 誕生日のお小遣い // https://yukicoder.me/problems/no/604 // #include #include #include using namespace std; unsigned long long int solve(unsigned long long int A, unsigned long long int B, unsigned long long int C); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); unsigned long long A, B, C; cin >> A >> B >> C; unsigned long long ans = solve(A, B, C); cout << ans << endl; } unsigned long long int solve(unsigned long long int A, unsigned long long int B, unsigned long long int C) { if (A == 1) { unsigned long long ans = C / B; if (C % B != 0) ++ans; return ans; } unsigned long long cycle_income = B + (A - 1); unsigned long long cycle = C / cycle_income; unsigned long long ans1 = C - (cycle_income * cycle) + A * cycle; unsigned long long ans2 = (cycle + 1) * A; return min(ans1, ans2); }