原题链接:https://ac.nowcoder.com/acm/problem/257491
目录
1. 题目描述
2. 思路分析
用set模拟。依次删除set的第一个元素,然后再插入t+a和t+b,重复k次即可。
3. 代码实现
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int k, a, b; cin >> k >> a >> b;
set<int>s;
while (k--) {
int t = *s.begin();
s.erase(t);
s.insert(t + a);
s.insert(t + b);
}
cout << *s.begin() << endl;
return 0;
}